diff --git a/tslang/lib/TypeScript/MLIRGenImpl.h b/tslang/lib/TypeScript/MLIRGenImpl.h index 0deaffd38..283035c45 100644 --- a/tslang/lib/TypeScript/MLIRGenImpl.h +++ b/tslang/lib/TypeScript/MLIRGenImpl.h @@ -9842,7 +9842,11 @@ class MLIRGenImpl auto cont = mlir::TypeSwitch(type) .Case([&](auto ifaceType) { auto interfaceInfo = getInterfaceInfoByFullName(ifaceType.getName().getValue()); - assert(interfaceInfo); + if (!interfaceInfo) + { + // not registered (e.g. forward/ambient reference), nothing to export + return true; + } for (auto& method : interfaceInfo->methods) { @@ -9858,7 +9862,11 @@ class MLIRGenImpl }) .Case([&](auto classType) { auto classInfo = getClassInfoByFullName(classType.getName().getValue()); - assert(classInfo); + if (!classInfo) + { + // not registered (e.g. forward/ambient reference), nothing to export + return true; + } for (auto& method : classInfo->methods) { @@ -9903,20 +9911,33 @@ class MLIRGenImpl auto cont = mlir::TypeSwitch(type) .Case([&](auto ifaceType) { auto interfaceInfo = getInterfaceInfoByFullName(ifaceType.getName().getValue()); - assert(interfaceInfo); + if (!interfaceInfo) + { + // not registered (e.g. forward/ambient reference), nothing to export + return true; + } + addInterfaceDeclarationToExport(interfaceInfo); return true; }) .Case([&](auto classType) { auto classInfo = getClassInfoByFullName(classType.getName().getValue()); - assert(classInfo); + if (!classInfo) + { + // not registered (e.g. forward/ambient reference), nothing to export + return true; + } + addClassDeclarationToExport(classInfo); return true; }) .Case([&](auto enumType) { auto enumInfo = getEnumInfoByFullName(enumType.getName().getValue()); - assert(enumInfo); - assert(enumInfo->enumType == enumType); + if (!enumInfo || enumInfo->enumType != enumType) + { + // not registered (e.g. forward/ambient reference), nothing to export + return true; + } addEnumDeclarationToExport(enumInfo->name, enumInfo->elementNamespace, enumType); return true; @@ -9926,7 +9947,7 @@ class MLIRGenImpl }); return cont; - } + } void addTypeDeclarationToExport(StringRef name, NamespaceInfo::TypePtr elementNamespace, mlir::Type type) {