diff options
| author | Yong He <yonghe@outlook.com> | 2023-11-06 14:40:38 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-06 14:40:38 -0800 |
| commit | 46529df2c4f73a4655bdd79d48004f29374a99a8 (patch) | |
| tree | 801e69e70a47ce702c055df68ada41a38158367b /source/slang/slang-check-decl.cpp | |
| parent | da9e0adb5cf2b1bed6075a3afe93cfdcceabe904 (diff) | |
Fix ICE when lowering an associatedtype declref from an derived interface. (#3312)
* Fix ICE when lowering an associatedtype declref from an derived interface.
* Fixes.
* Fix test.
* Fix GLSL/SPIRV image subscript swizzle store regression.
* Fix.
---------
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 | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 03d9f0d9e..8d7337318 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2937,6 +2937,17 @@ namespace Slang // With the big picture spelled out, we can settle into // the work of constructing our synthesized method. // + + // First, we check that the differentiabliity of the method matches the requirement, + // and we don't attempt to synthesize a method if they don't match. + if (getShared()->getFuncDifferentiableLevel( + as<FunctionDeclBase>(lookupResult.item.declRef.getDecl())) + < getShared()->getFuncDifferentiableLevel( + as<FunctionDeclBase>(requiredMemberDeclRef.getDecl()))) + { + return false; + } + ThisExpr* synThis = nullptr; List<Expr*> synArgs; auto synFuncDecl = synthesizeMethodSignatureForRequirementWitness( @@ -3945,8 +3956,15 @@ namespace Slang // and if nothing is found we print the candidates that made it // furthest in checking. // - getSink()->diagnose(inheritanceDecl, Diagnostics::typeDoesntImplementInterfaceRequirement, subType, requiredMemberDeclRef); - getSink()->diagnose(requiredMemberDeclRef, Diagnostics::seeDeclarationOf, requiredMemberDeclRef); + if (!lookupResult.isOverloaded() && lookupResult.isValid()) + { + getSink()->diagnose(lookupResult.item.declRef, Diagnostics::memberDoesNotMatchRequirementSignature, lookupResult.item.declRef); + } + else + { + getSink()->diagnose(inheritanceDecl, Diagnostics::typeDoesntImplementInterfaceRequirement, subType, requiredMemberDeclRef); + } + getSink()->diagnose(requiredMemberDeclRef, Diagnostics::seeDeclarationOfInterfaceRequirement, requiredMemberDeclRef); return false; } @@ -7004,6 +7022,9 @@ namespace Slang FunctionDifferentiableLevel SharedSemanticsContext::_getFuncDifferentiableLevelImpl(FunctionDeclBase* func, int recurseLimit) { + if (!func) + return FunctionDifferentiableLevel::None; + if (recurseLimit > 0) { if (auto primalSubst = func->findModifier<PrimalSubstituteAttribute>()) |
