Skip to content

Commit a18920f

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

File tree

4 files changed

+4599
-66
lines changed

4 files changed

+4599
-66
lines changed

src/compiler.ts

Lines changed: 18 additions & 16 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,28 +5810,29 @@ 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);
5829-
let getterInstance = assert((<Property>target).getterInstance);
5830-
return module.block(null, [
5831-
this.makeCallDirect(setterInstance, [ valueExpr ], valueExpression),
5832-
this.makeCallDirect(getterInstance, null, valueExpression)
5833-
], getterInstance.signature.returnType.toRef());
5826+
let tempLocal = flow.getTempLocal(valueType);
5827+
let valueTypeRef = valueType.toRef();
5828+
let ret = module.block(null, [
5829+
this.makeCallDirect(setterInstance, [
5830+
module.local_tee(tempLocal.index, valueExpr, valueType.isManaged, valueTypeRef),
5831+
], valueExpression),
5832+
module.local_get(tempLocal.index, valueTypeRef),
5833+
], valueTypeRef);
5834+
this.currentType = valueType;
5835+
return ret;
58345836
}
58355837
}
58365838
case ElementKind.IndexSignature: {

0 commit comments

Comments
 (0)