From 3bc57b174ee037bcc6e16c3d5fcd6743fa22af02 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 28 Apr 2022 11:09:58 -0700 Subject: [PATCH] Failover to unspecialized type name in GetGenericTypeInstances --- IDEHelper/Compiler/BfCompiler.cpp | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 2575b7d3..2bb08447 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -10309,9 +10309,37 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetGenericTypeInstances(BfCompiler* String& outString = *gTLStrReturn.Get(); outString = ""; - auto lookupType = bfCompiler->GetType(typeName); + String checkTypeName = typeName; + auto lookupType = bfCompiler->GetType(checkTypeName); if (lookupType == NULL) - return ""; + { + // Sanitize potentially-generic type name into an unspecialized type name + int chevronDepth = 0; + int chevronStart = -1; + for (int i = 0; i < (int)checkTypeName.mLength; i++) + { + char c = checkTypeName[i]; + if (c == '<') + { + if (chevronDepth == 0) + chevronStart = i; + chevronDepth++; + } + else if (c == '>') + { + chevronDepth--; + if (chevronDepth == 0) + { + checkTypeName.Remove(chevronStart + 1, i - chevronStart - 1); + i = chevronStart + 1; + } + } + } + + lookupType = bfCompiler->GetType(checkTypeName); + if (lookupType == NULL) + return ""; + } auto lookupTypeInst = lookupType->ToTypeInstance(); if (lookupTypeInst == NULL)