From 46529df2c4f73a4655bdd79d48004f29374a99a8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 6 Nov 2023 14:40:38 -0800 Subject: 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 --- source/slang/slang-check-decl.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-check-decl.cpp') 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(lookupResult.item.declRef.getDecl())) + < getShared()->getFuncDifferentiableLevel( + as(requiredMemberDeclRef.getDecl()))) + { + return false; + } + ThisExpr* synThis = nullptr; List 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()) -- cgit v1.2.3