Skip to content

Commit

Permalink
synthesized Dispose() fixes
Browse files Browse the repository at this point in the history
- fixes Dispose() IL
- ref #489
  • Loading branch information
jakubmisek committed Sep 14, 2019
1 parent 4ec4469 commit 92daf0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Peachpie.CodeAnalysis/CodeGen/Symbols/SourceTypeSymbol.cs
Expand Up @@ -148,7 +148,7 @@ void EmitDisposable(Emit.PEModuleBuilder module, DiagnosticBag diagnostics)
//
// IDisposable.Dispose()
//
var dispose = new SynthesizedMethodSymbol(this, "IDisposable.Dispose", false, true, DeclaringCompilation.GetSpecialType(SpecialType.System_Void), isfinal: false)
var dispose = new SynthesizedMethodSymbol(this, "IDisposable.Dispose", false, true, DeclaringCompilation.GetSpecialType(SpecialType.System_Void), isfinal: true)
{
ExplicitOverride = (MethodSymbol)DeclaringCompilation.GetSpecialTypeMember(SpecialMember.System_IDisposable__Dispose),
ForwardedCall = __destruct,
Expand Down Expand Up @@ -180,7 +180,10 @@ void EmitDisposable(Emit.PEModuleBuilder module, DiagnosticBag diagnostics)
disposedPlace.EmitStore(cg.Builder);
// __destruct()
cg.EmitRet(cg.EmitForwardCall(__destruct, dispose, callvirt: true));
cg.EmitPop(cg.EmitForwardCall(__destruct, dispose, callvirt: true));
// .ret
cg.EmitRet(DeclaringCompilation.GetSpecialType(SpecialType.System_Void));
}, null, diagnostics, false));

Expand Down
Expand Up @@ -41,7 +41,7 @@ public SynthesizedFinalizeSymbol(NamedTypeSymbol/*!*/container)

public sealed override MethodKind MethodKind => MethodKind.Destructor;

internal override bool IsExplicitInterfaceImplementation => false;
internal override bool IsExplicitInterfaceImplementation => true;

internal override ObsoleteAttributeData ObsoleteAttributeData => null;

Expand Down

0 comments on commit 92daf0f

Please sign in to comment.