diff options
| author | Yong He <yonghe@outlook.com> | 2023-10-25 07:45:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-25 22:45:23 +0800 |
| commit | f8bf75cf1ae0aeee155996a917c2925bc500f3e2 (patch) | |
| tree | 07b418cfdc3fe106c492162624cfdaeb7a453be9 /source/slang/slang-check-decl.cpp | |
| parent | d8f4c9424c69a3d406fabf56a25dd3eda4bc7d51 (diff) | |
Support generic interfaces. (#3278)
* Initial support for generic interfaces.
* Cleanup.
* Add generic syntax for interfaces.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 1e3c6a361..8df5ae618 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -169,6 +169,8 @@ namespace Slang void visitInheritanceDecl(InheritanceDecl* inheritanceDecl); + void visitThisTypeConstraintDecl(ThisTypeConstraintDecl* thisTypeConstraintDecl); + /// Validate that `decl` isn't illegally inheriting from a type in another module. /// /// This call checks a single `inheritanceDecl` to make sure that it either @@ -1600,6 +1602,22 @@ namespace Slang // based on the declaration that is doing the inheriting. } + void SemanticsDeclBasesVisitor::visitThisTypeConstraintDecl(ThisTypeConstraintDecl* thisTypeConstraintDecl) + { + // Make sure IFoo<T>.This.ThisIsIFooConstraint.base.type is properly set + // to DeclRefType(IFoo<T>) with default generic arguments. + if (!thisTypeConstraintDecl->base.type) + { + auto parentTypeDecl = getParentDecl(getParentDecl(thisTypeConstraintDecl)); + thisTypeConstraintDecl->base.type = DeclRefType::create( + m_astBuilder, + createDefaultSubstitutionsIfNeeded( + m_astBuilder, + this, + getDefaultDeclRef(parentTypeDecl))); + } + } + // Concretize interface conformances so that we have witnesses as required for lookup. // for lookup. struct SemanticsDeclConformancesVisitor |
