summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-21 20:03:12 -0700
committerGitHub <noreply@github.com>2023-03-21 20:03:12 -0700
commit83876733d69582eec6bad26af64a651d40fa43aa (patch)
tree641edb23ee4d656b198e1cc840470702f3ac391d /source/slang/slang-check-expr.cpp
parent5d2c5dd9f748d728abf2a4361fca71a7f9ec65b6 (diff)
Fix associated type resolution bug. (#2719)
* Fix associated type resolution bug. * Fix. * Fix language server hinting messed up by breadcrumb nodes. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 8d8a72dd6..bfad1dbfe 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -487,12 +487,25 @@ namespace Slang
switch (builtinAssocTypeAttr->kind)
{
case BuiltinRequirementKind::DifferentialType:
- synthesizedDecl = m_astBuilder->create<StructDecl>();
+ {
+ auto structDecl = m_astBuilder->create<StructDecl>();
+ auto conformanceDecl = m_astBuilder->create<InheritanceDecl>();
+ conformanceDecl->base.type = m_astBuilder->getDiffInterfaceType();
+ conformanceDecl->parentDecl = structDecl;
+ structDecl->members.add(conformanceDecl);
+
+ synthesizedDecl = structDecl;
+ auto typeDef = m_astBuilder->create<TypeAliasDecl>();
+ typeDef->nameAndLoc.name = getName("Differential");
+ auto declRef = createDefaultSubstitutionsIfNeeded(m_astBuilder, this, DeclRef<Decl>(structDecl, nullptr));
+ typeDef->type.type = m_astBuilder->getOrCreateDeclRefType(declRef.decl, declRef.substitutions);
+ typeDef->parentDecl = structDecl;
+ structDecl->members.add(typeDef);
+ }
break;
default:
- break;
+ return nullptr;
}
- synthesizedDecl = m_astBuilder->create<StructDecl>();
synthesizedDecl->parentDecl = parent;
synthesizedDecl->nameAndLoc.name = item.declRef.getName();
synthesizedDecl->loc = parent->loc;
@@ -645,6 +658,15 @@ namespace Slang
default:
SLANG_UNREACHABLE("all cases handle");
}
+ if (getShared()->isInLanguageServer())
+ {
+ // Don't make breadcrumb nodes carry any source loc info,
+ // as they may confuse language server functionalities.
+ if (bb)
+ {
+ bb->loc = SourceLoc();
+ }
+ }
}
return ConstructDeclRefExpr(item.declRef, bb, loc, originalExpr);