summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-parser.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-10-25 07:45:23 -0700
committerGitHub <noreply@github.com>2023-10-25 22:45:23 +0800
commitf8bf75cf1ae0aeee155996a917c2925bc500f3e2 (patch)
tree07b418cfdc3fe106c492162624cfdaeb7a453be9 /source/slang/slang-parser.cpp
parentd8f4c9424c69a3d406fabf56a25dd3eda4bc7d51 (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-parser.cpp')
-rw-r--r--source/slang/slang-parser.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 696575f8b..59aff4dc0 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -3061,7 +3061,7 @@ namespace Slang
parser->FillPosition(paramConstraint);
// substitution needs to be filled during check
- DeclRefType* paramType = DeclRefType::create(parser->astBuilder, DeclRef<Decl>(decl));
+ Type* paramType = DeclRefType::create(parser->astBuilder, DeclRef<Decl>(decl));
SharedTypeExpr* paramTypeExpr = parser->astBuilder->create<SharedTypeExpr>();
paramTypeExpr->loc = decl->loc;
@@ -3128,12 +3128,14 @@ namespace Slang
AdvanceIf(parser, TokenType::CompletionRequest);
decl->nameAndLoc = NameLoc(parser->ReadToken(TokenType::Identifier));
-
- parseOptionalInheritanceClause(parser, decl);
-
- parseDeclBody(parser, decl);
-
- return decl;
+ return parseOptGenericDecl(parser, [&](GenericDecl*)
+ {
+ // We allow for an inheritance clause on a `struct`
+ // so that it can conform to interfaces.
+ parseOptionalInheritanceClause(parser, decl);
+ parseDeclBody(parser, decl);
+ return decl;
+ });
}
static NodeBase* parseNamespaceDecl(Parser* parser, void* /*userData*/)