From 9b1b97d2b770cefcefe41f4e53ec7b5c95047e1d Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Fri, 16 Aug 2019 17:06:58 +0200 Subject: [PATCH] Do not retain unmanaged allocations in generated ctors (#762) --- src/compiler.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compiler.ts b/src/compiler.ts index b8b378132d..e3d4a3f16e 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -7871,16 +7871,14 @@ export class Compiler extends DiagnosticEmitter { // this.b = Y // return this // } + var allocExpr = this.makeAllocation(classInstance); + if (classInstance.type.isManaged) allocExpr = this.makeRetain(allocExpr); stmts.push( module.if( module.unary(nativeSizeType == NativeType.I64 ? UnaryOp.EqzI64 : UnaryOp.EqzI32, module.local_get(0, nativeSizeType) ), - module.local_set(0, - this.makeRetain( - this.makeAllocation(classInstance) - ) - ) + module.local_set(0, allocExpr) ) ); if (baseClass) {