Skip to content

Commit f40e4a3

Browse files
committed
fix: avoid use getInstance in assignment chain
1 parent 3049d3c commit f40e4a3

File tree

4 files changed

+4518
-61
lines changed

4 files changed

+4518
-61
lines changed

src/compiler.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5801,6 +5801,7 @@ export class Compiler extends DiagnosticEmitter {
58015801
return module.unreachable();
58025802
}
58035803
assert(setterInstance.signature.parameterTypes.length == 1);
5804+
assert(setterInstance.signature.returnType == Type.void);
58045805
if (propertyInstance.is(CommonFlags.Instance)) {
58055806
let thisType = assert(setterInstance.signature.thisType);
58065807
let thisExpr = this.compileExpression(
@@ -5809,20 +5810,16 @@ export class Compiler extends DiagnosticEmitter {
58095810
Constraints.ConvImplicit | Constraints.IsThis
58105811
);
58115812
if (!tee) return this.makeCallDirect(setterInstance, [ thisExpr, valueExpr ], valueExpression);
5812-
let getterInstance = assert((<Property>target).getterInstance);
5813-
assert(getterInstance.signature.thisType == thisType);
5814-
let returnType = getterInstance.signature.returnType;
5815-
let returnTypeRef = returnType.toRef();
5816-
let tempThis = flow.getTempLocal(thisType);
5813+
let tempLocal = flow.getTempLocal(valueType);
5814+
let valueTypeRef = valueType.toRef();
58175815
let ret = module.block(null, [
58185816
this.makeCallDirect(setterInstance, [
5819-
module.local_tee(tempThis.index, thisExpr, /* isManaged=*/false, thisType.toRef()), // thisType is managed but here it must be alive
5820-
valueExpr
5817+
thisExpr,
5818+
module.local_tee(tempLocal.index, valueExpr, valueType.isManaged, valueTypeRef)
58215819
], valueExpression),
5822-
this.makeCallDirect(getterInstance, [
5823-
module.local_get(tempThis.index, thisType.toRef())
5824-
], valueExpression)
5825-
], returnTypeRef);
5820+
module.local_get(tempLocal.index, valueTypeRef),
5821+
], valueTypeRef);
5822+
this.currentType = valueType;
58265823
return ret;
58275824
} else {
58285825
if (!tee) return this.makeCallDirect(setterInstance, [ valueExpr ], valueExpression);

0 commit comments

Comments
 (0)