diff options
| author | Yong He <yonghe@outlook.com> | 2020-08-21 01:10:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-21 01:10:45 -0700 |
| commit | a8bc5983eae60ca37e853041e989a654c1247876 (patch) | |
| tree | 330cae10c2c24ba14ca726b61c576d9f362f5b8e /source/slang/slang-ast-type.cpp | |
| parent | 11748a75e66c2bd3fa7ef7635fd35363465f599c (diff) | |
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 <tfoleyNV@users.noreply.github.com>
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-type.cpp')
| -rw-r--r-- | source/slang/slang-ast-type.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<ExtractExistentialType>(); - substValue->declRef = declRef; + substValue->declRef = substDeclRef; + substValue->interfaceDeclRef = interfaceSubstDeclRef; return substValue; } |
