Skip to content

Commit

Permalink
fix for ambiguous type declaration
Browse files Browse the repository at this point in the history
fixes #1063
in case of traits, the constructed type cannot be compared with
  • Loading branch information
jakubmisek committed Sep 7, 2022
1 parent 5d22ff2 commit c565c02
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Peachpie.CodeAnalysis/CodeGen/CodeGenerator.Emit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3639,8 +3639,16 @@ void EmitVersionedTypeDeclaration(ImmutableArray<SourceTypeSymbol> versions)

// Template: *recursion*
// h == thandle: filter versions depending on thandle
var filtered_versions = versions.Where(v => v.GetDependentSourceTypeSymbols().Contains(h));
EmitDeclareTypeByDependencies(filtered_versions.AsImmutable(), dependency_handle, index + 1, dependencies, lblDone, lblFail);
var filtered_versions = versions.Where(v => v.GetDependentSourceTypeSymbols().Any(d => d.OriginalDefinition == h.OriginalDefinition)).AsImmutable();
if (filtered_versions.IsEmpty)
{
// no version depends on {h}
// https://github.com/peachpiecompiler/peachpie/issues/1063
Debug.Fail($"unexpected, no version depends on '{h}'");
continue;
}

EmitDeclareTypeByDependencies(filtered_versions, dependency_handle, index + 1, dependencies, lblDone, lblFail);
}
_il.MarkLabel(lblElse);
_il.EmitBranch(ILOpCode.Br, lblFail);
Expand Down

0 comments on commit c565c02

Please sign in to comment.