summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-07-11 13:46:21 -0400
committerGitHub <noreply@github.com>2024-07-11 13:46:21 -0400
commit977e4b21d69406b0b68c5963f50489d7433db830 (patch)
treeaf5e68f910c1887ef3c638d8620449ab66d9faf3 /source
parentc3061afffdc078914cc522538749c6e0c5e36f65 (diff)
Fix issue with synthesizing `Differential` type for self-differential generic types (#4602)
* Fix issue with synthesizing `Differential` type for self-differential generic types The problem was that we were using the type that was performing the lookup for `.Differential` which can have substitutions based on the local context where the decl is being referenced. We need to synthesize the type local to the decl itself * Update auto-differential-type-generic.slang
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-expr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index ee36a21fb..f60ead1e9 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -638,7 +638,12 @@ namespace Slang
auto typeDef = m_astBuilder->create<TypeAliasDecl>();
typeDef->nameAndLoc.name = item.declRef.getName();
typeDef->parentDecl = parent;
- typeDef->type.type = subType;
+
+ // Compute the decl's type as if it is referred to from itself. This is important because
+ // subType may have substitutions from the context it is used in, while this synthesis step
+ // is local to the decl.
+ //
+ typeDef->type.type = calcThisType(subType->getDeclRef().getDecl()->getDefaultDeclRef());
synthesizedDecl = parent;