@@ -154,39 +154,73 @@ private module SetterDesugar {
154154 * desugars to
155155 *
156156 * ```rb
157- * x.foo=(y)
157+ * x.foo=(__synth_0 = y);
158+ * __synth_0;
158159 * ```
159160 */
160161 private class SetterMethodCallSynthesis extends Synthesis {
161162 final override predicate child ( AstNode parent , int i , Child child , LocationOption l ) {
162163 exists ( AssignExpr ae , MethodCall mc | mc = ae .getLeftOperand ( ) |
163164 parent = ae and
164165 i = - 1 and
165- child = SynthChild ( getCallKind ( mc ) ) and
166- l = getSomeLocation ( mc )
166+ child = SynthChild ( StmtSequenceKind ( ) ) and
167+ l = NoneLocation ( )
167168 or
168- parent = getSynthChild ( ae , - 1 ) and
169- l = NoneLocation ( ) and
170- (
169+ exists ( AstNode seq | seq = getSynthChild ( ae , - 1 ) |
170+ parent = seq and
171171 i = 0 and
172- child = RealChild ( mc .getReceiver ( ) )
173- or
174- child = RealChild ( mc .getArgument ( i - 1 ) )
172+ child = SynthChild ( getCallKind ( mc ) ) and
173+ l = getSomeLocation ( mc )
175174 or
176- i = mc .getNumberOfArguments ( ) + 1 and
177- child = RealChild ( ae .getRightOperand ( ) )
175+ exists ( AstNode call | call = getSynthChild ( seq , 0 ) |
176+ parent = call and
177+ i = 0 and
178+ child = RealChild ( mc .getReceiver ( ) ) and
179+ l = NoneLocation ( )
180+ or
181+ parent = call and
182+ child = RealChild ( mc .getArgument ( i - 1 ) ) and
183+ l = NoneLocation ( )
184+ or
185+ l = getSomeLocation ( mc ) and
186+ exists ( int valueIndex | valueIndex = mc .getNumberOfArguments ( ) + 1 |
187+ parent = call and
188+ i = valueIndex and
189+ child = SynthChild ( AssignExprKind ( ) )
190+ or
191+ parent = getSynthChild ( call , valueIndex ) and
192+ (
193+ i = 0 and
194+ child = SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( ae , 0 ) ) )
195+ or
196+ i = 1 and
197+ child = RealChild ( ae .getRightOperand ( ) )
198+ )
199+ )
200+ or
201+ parent = call and
202+ // special "number of arguments argument"; required to avoid non-monotonic recursion
203+ i = - 2 and
204+ child = SynthChild ( IntegerLiteralKind ( mc .getNumberOfArguments ( ) + 1 ) ) and
205+ l = NoneLocation ( )
206+ )
178207 or
179- // special "number of arguments argument"; required to avoid non-monotonic recursion
180- i = - 2 and
181- child = SynthChild ( IntegerLiteralKind ( mc . getNumberOfArguments ( ) + 1 ) ) and
182- l = NoneLocation ( )
208+ parent = seq and
209+ i = 1 and
210+ child = SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( ae , 0 ) ) ) and
211+ l = getSomeLocation ( mc )
183212 )
184213 )
185214 }
186215
187216 final override predicate excludeFromControlFlowTree ( AstNode n ) {
188217 n .( MethodCall ) = any ( AssignExpr ae ) .getLeftOperand ( )
189218 }
219+
220+ final override predicate localVariable ( AstNode n , int i ) {
221+ n .( AssignExpr ) .getLeftOperand ( ) instanceof MethodCall and
222+ i = 0
223+ }
190224 }
191225}
192226
0 commit comments