From fd24ab21af816f45d5892c3813f5576f5bdf7468 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 24 Jan 2025 10:16:22 -0800 Subject: [PATCH] Fixed incorrectly applied method generic constraints in constraint check --- IDEHelper/Compiler/BfModule.cpp | 2 +- IDEHelper/Tests/src/Mixins.bf | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 7b888eb6..2775fc21 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/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; } diff --git a/IDEHelper/Tests/src/Mixins.bf b/IDEHelper/Tests/src/Mixins.bf index 2f6ffda9..2f665d40 100644 --- a/IDEHelper/Tests/src/Mixins.bf +++ b/IDEHelper/Tests/src/Mixins.bf @@ -97,6 +97,33 @@ namespace Tests } } + public static mixin Test(T a) where T : struct {} + public static mixin Test(Type value) {} + public static mixin Test(T a) where T : class, delete {} + + public class TestClass + { + public bool CallTest(TValue val) + where TValue : var + { + SelfOuter.Test!(val); + return true; + } + } + + public static mixin Test2(T a) where T : struct {} + public static mixin Test2(T a) where T : class, delete {} + + public class TestClass2 + { + public bool CallTest(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(); + test2.CallTest(2); + + let test3 = scope TestClass2(); + test3.CallTest(2); } [Test]