Skip to content

Commit aad4b3e

Browse files
committed
Fix constructor call
1 parent 5522a3c commit aad4b3e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

jacodb-ets/src/main/kotlin/org/jacodb/ets/dto/ConvertToEts.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ import org.jacodb.ets.model.EtsUnsignedRightShiftExpr
127127
import org.jacodb.ets.model.EtsValue
128128
import org.jacodb.ets.model.EtsVoidType
129129
import org.jacodb.ets.model.EtsYieldExpr
130+
import org.jacodb.ets.utils.CONSTRUCTOR_NAME
131+
132+
/**
133+
* Ad-hoc fix for constructor call.
134+
*
135+
* Replaces `x := x.constructor(...)` with `x.constructor(...)` call stmt.
136+
*/
137+
fun EtsAssignStmt.fixConstructorCall(): EtsStmt =
138+
if (lhv is EtsLocal &&
139+
rhv is EtsInstanceCallExpr &&
140+
rhv.instance == lhv &&
141+
rhv.callee.name == CONSTRUCTOR_NAME
142+
) {
143+
EtsCallStmt(location, rhv)
144+
} else {
145+
this
146+
}
130147

131148
class EtsMethodBuilder(
132149
signature: EtsMethodSignature,
@@ -209,7 +226,7 @@ class EtsMethodBuilder(
209226
location = loc(),
210227
lhv = lhv,
211228
rhv = rhv,
212-
)
229+
).fixConstructorCall()
213230
}
214231

215232
is CallStmtDto -> {

0 commit comments

Comments
 (0)