From a8bc5983eae60ca37e853041e989a654c1247876 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 21 Aug 2020 01:10:45 -0700 Subject: Allow calling a generic function with an existential value (dynamic dispatch) (#1508) * Allow calling a generic function with an existential value (dynamic dispatch). * Fixes per review comments. * Clean up implementation by having `openExistential` return `ExtractExistentialType` instead of a DeclRef to the interface with a `ThisTypeSubstitution`. * More cleanups Co-authored-by: Tim Foley Co-authored-by: Yong He --- source/slang/slang-ast-type.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ast-type.cpp') diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp index f5feb4d64..55bb9a1e5 100644 --- a/source/slang/slang-ast-type.cpp +++ b/source/slang/slang-ast-type.cpp @@ -676,7 +676,7 @@ bool ExtractExistentialType::_equalsImplOverride(Type* type) HashCode ExtractExistentialType::_getHashCodeOverride() { - return declRef.getHashCode(); + return combineHash(declRef.getHashCode(), interfaceDeclRef.getHashCode()); } Type* ExtractExistentialType::_createCanonicalTypeOverride() @@ -688,13 +688,15 @@ Val* ExtractExistentialType::_substituteImplOverride(ASTBuilder* astBuilder, Sub { int diff = 0; auto substDeclRef = declRef.substituteImpl(astBuilder, subst, &diff); + auto interfaceSubstDeclRef = interfaceDeclRef.substituteImpl(astBuilder, subst, &diff); if (!diff) return this; (*ioDiff)++; ExtractExistentialType* substValue = astBuilder->create(); - substValue->declRef = declRef; + substValue->declRef = substDeclRef; + substValue->interfaceDeclRef = interfaceSubstDeclRef; return substValue; } -- cgit v1.2.3