Skip to content

Commit 37f27b1

Browse files
authored
Do not retain unmanaged allocations in generated ctors (AssemblyScript#762)
1 parent a7b9244 commit 37f27b1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/compiler.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7871,16 +7871,14 @@ export class Compiler extends DiagnosticEmitter {
78717871
// this.b = Y
78727872
// return this
78737873
// }
7874+
var allocExpr = this.makeAllocation(classInstance);
7875+
if (classInstance.type.isManaged) allocExpr = this.makeRetain(allocExpr);
78747876
stmts.push(
78757877
module.if(
78767878
module.unary(nativeSizeType == NativeType.I64 ? UnaryOp.EqzI64 : UnaryOp.EqzI32,
78777879
module.local_get(0, nativeSizeType)
78787880
),
7879-
module.local_set(0,
7880-
this.makeRetain(
7881-
this.makeAllocation(classInstance)
7882-
)
7883-
)
7881+
module.local_set(0, allocExpr)
78847882
)
78857883
);
78867884
if (baseClass) {

0 commit comments

Comments
 (0)