summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-lower-generic-function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-lower-generic-function.cpp')
-rw-r--r--source/slang/slang-ir-lower-generic-function.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/source/slang/slang-ir-lower-generic-function.cpp b/source/slang/slang-ir-lower-generic-function.cpp
index f2b1d1a6a..c003d6125 100644
--- a/source/slang/slang-ir-lower-generic-function.cpp
+++ b/source/slang/slang-ir-lower-generic-function.cpp
@@ -296,8 +296,11 @@ struct GenericFunctionLoweringContext
// and emission of wrapper functions.
void lowerWitnessTable(IRWitnessTable* witnessTable)
{
- auto interfaceType =
- maybeLowerInterfaceType(cast<IRInterfaceType>(witnessTable->getConformanceType()));
+ IRInterfaceType* conformanceType = as<IRInterfaceType>(witnessTable->getConformanceType());
+ if (!conformanceType)
+ return;
+
+ auto interfaceType = maybeLowerInterfaceType(conformanceType);
IRBuilder builderStorage(sharedContext->module);
auto builder = &builderStorage;
builder->setInsertBefore(witnessTable);
@@ -353,8 +356,17 @@ struct GenericFunctionLoweringContext
return;
if (witnessTableType->getConformanceType()->findDecoration<IRComInterfaceDecoration>())
return;
- auto interfaceType =
- maybeLowerInterfaceType(cast<IRInterfaceType>(witnessTableType->getConformanceType()));
+
+ IRInterfaceType* conformanceType =
+ as<IRInterfaceType>(witnessTableType->getConformanceType());
+
+ // NoneWitness generates conformance types which aren't interfaces. In
+ // that case, the method can just be skipped entirely, since there's no
+ // real witness for it and it should be in unreachable code at this
+ // point.
+ if (!conformanceType)
+ return;
+ auto interfaceType = maybeLowerInterfaceType(conformanceType);
interfaceRequirementVal = sharedContext->findInterfaceRequirementVal(
interfaceType,
lookupInst->getRequirementKey());