Kaynağa Gözat

Fixed incorrectly applied method generic constraints in constraint check

Brian Fiete 7 ay önce
ebeveyn
işleme
fd24ab21af
2 değiştirilmiş dosya ile 34 ekleme ve 1 silme
  1. 1 1
      IDEHelper/Compiler/BfModule.cpp
  2. 33 0
      IDEHelper/Tests/src/Mixins.bf

+ 1 - 1
IDEHelper/Compiler/BfModule.cpp

@@ -8705,7 +8705,7 @@ bool BfModule::CheckGenericConstraints(const BfGenericParamSource& genericParamS
 		{
 			auto genericParamInst = mCurMethodInstance->mMethodInfoEx->mGenericParams[genericParamIdx];
 					
- 			if (genericParamInst->mExternType == checkArgType)
+ 			if ((genericParamInst->mExternType == checkArgType) && (checkArgType->IsUnspecializedType()))
  			{
 				checkGenericParamFlags |= genericParamInst->mGenericParamFlags; 				
  			}

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

@@ -97,6 +97,33 @@ namespace Tests
 			}
 		}
 
+		public static mixin Test<T>(T a) where T : struct {}
+		public static mixin Test(Type value) {}
+		public static mixin Test<T>(T a) where T : class, delete {}
+
+		public class TestClass<TValue>
+		{
+			public bool CallTest<T>(TValue val)
+				where TValue : var
+			{
+				SelfOuter.Test!(val);
+				return true;
+			}
+		}
+
+		public static mixin Test2<T>(T a) where T : struct {}
+		public static mixin Test2<T>(T a) where T : class, delete {}
+
+		public class TestClass2<TValue>
+		{
+			public bool CallTest<T>(TValue val)
+				where TValue : var
+			{
+				SelfOuter.Test2!(val);
+				return true;
+			}
+		}
+
 		[Test]
 		public static void TestBasics()
 		{
@@ -130,6 +157,12 @@ namespace Tests
 
 			DispClass dc = scope .();
 			DisposeIt!(dc);
+
+			let test2 = scope TestClass<int>();
+			test2.CallTest<int>(2);
+
+			let test3 = scope TestClass2<int>();
+			test3.CallTest<int>(2);
 		}
 
 		[Test]