Browse Source

GetActiveTypeDef mixin issue in GetActiveTypeGenericParamInstances

Brian Fiete 7 months ago
parent
commit
2f7616cd40
2 changed files with 36 additions and 1 deletions
  1. 3 1
      IDEHelper/Compiler/BfModuleTypeUtils.cpp
  2. 33 0
      IDEHelper/Tests/src/Mixins.bf

+ 3 - 1
IDEHelper/Compiler/BfModuleTypeUtils.cpp

@@ -9629,7 +9629,9 @@ void BfModule::GetActiveTypeGenericParamInstances(SizedArray<BfGenericParamInsta
 
 	if (genericTypeInst->mGenericTypeInfo->mGenericExtensionInfo != NULL)
 	{
-		auto activeTypeDef = GetActiveTypeDef(NULL, true);
+		// Note: original version had useMixinDecl set. Was there a reason for that? Causes issue 2118
+		auto activeTypeDef = GetActiveTypeDef(NULL);
+
 		if ((activeTypeDef->mTypeDeclaration != genericTypeInst->mTypeDef->mTypeDeclaration) && (activeTypeDef->IsExtension()))
 		{
 			BfTypeDef* lookupTypeDef = activeTypeDef;

+ 33 - 0
IDEHelper/Tests/src/Mixins.bf

@@ -124,6 +124,37 @@ namespace Tests
 			}
 		}
 
+		class Foo<T, T2> where T : class
+		{
+			static void Test ()
+			{
+				Helper<T>.Pop!<int>();
+			}
+		}
+
+		extension Foo<T, T2>
+		{
+
+		}
+
+		class Helper<T>
+		{
+
+		}
+
+		extension Helper<T>
+		{
+			static public mixin Pop<TVal> ()
+			{
+				Pop2<int>()
+			}
+
+			static public T Pop2<TVal> () where TVal : var, struct, INumeric
+			{
+				return default;
+			}
+		}
+
 		[Test]
 		public static void TestBasics()
 		{
@@ -198,6 +229,8 @@ namespace Tests
 			var sv2 = Unwrap!(svRes)..Trim();
 			Test.Assert(svRes.Value == "ab ");
 			Test.Assert(sv2 == "ab");
+
+			Helper<int>.Pop!<float>();
 		}
 
 	}