From 79c9f5d8182c9e1e0795ad6b26b6225984f8f102 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 26 Aug 2020 06:10:36 -0700 Subject: [PATCH] Fixed generic interference with generic tuples --- IDE/src/IDEApp.bf | 13 ++++++++ IDE/src/ScriptManager.bf | 2 +- IDE/src/ui/StatusBar.bf | 2 +- IDEHelper/Compiler/BfExprEvaluator.cpp | 43 ++++++++++++-------------- IDEHelper/Tests/scripts/Test.txt | 3 ++ bin/test_ide.bat | 4 +++ 6 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 IDEHelper/Tests/scripts/Test.txt diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index c4bd2b8d..5489fad6 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -4576,12 +4576,24 @@ namespace IDE dialog.PopupWindow(mMainWindow); } + [IDECommand] + public void SelectConfig(String config) + { + mMainFrame.mStatusBar.SelectConfig(config); + } + [IDECommand] public void SelectConfig() { mMainFrame.mStatusBar.mConfigComboBox.ShowDropdown(); } + [IDECommand] + public void SelectPlatform(String platform) + { + mMainFrame.mStatusBar.SelectPlatform(platform); + } + [IDECommand] public void SelectPlatform() { @@ -4887,6 +4899,7 @@ namespace IDE return (mTestManager != null); } + [IDECommand] protected void RunTests(bool includeIgnored, bool debug) { if (mOutputPanel != null) diff --git a/IDE/src/ScriptManager.bf b/IDE/src/ScriptManager.bf index 5407cfbf..7d2cd5d7 100644 --- a/IDE/src/ScriptManager.bf +++ b/IDE/src/ScriptManager.bf @@ -1015,7 +1015,7 @@ namespace IDE return true; if ((!ScriptManager.sActiveManager.mIsBuildScript) && (gApp.AreTestsRunning())) - return true; + return false; if (gApp.mDebugger.HasPendingDebugLoads()) return false; diff --git a/IDE/src/ui/StatusBar.bf b/IDE/src/ui/StatusBar.bf index 44beaee7..f2effe57 100644 --- a/IDE/src/ui/StatusBar.bf +++ b/IDE/src/ui/StatusBar.bf @@ -65,7 +65,7 @@ namespace IDE.ui MarkDirty(); } - void SelectPlatform(String platformName) + public void SelectPlatform(String platformName) { mPlatformComboBox.Label = platformName; gApp.mPlatformName.Set(platformName); diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 44d13271..69aa63f9 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -395,6 +395,24 @@ bool BfGenericInferContext::InferGenericArgument(BfMethodInstance* methodInstanc return true; } + if (wantType->IsTuple()) + { + if (argType->IsTuple()) + { + auto wantTupleType = (BfTupleType*)wantType; + auto argTupleType = (BfTupleType*)argType; + + if (wantTupleType->mFieldInstances.size() == argTupleType->mFieldInstances.size()) + { + for (int fieldIdx = 0; fieldIdx < (int)wantTupleType->mFieldInstances.size(); fieldIdx++) + { + InferGenericArgument(methodInstance, argTupleType->mFieldInstances[fieldIdx].mResolvedType, + wantTupleType->mFieldInstances[fieldIdx].mResolvedType, BfIRValue()); + } + } + } + } + if ((wantType->IsGenericTypeInstance()) && (wantType->IsUnspecializedTypeVariation())) { auto wantGenericType = (BfTypeInstance*)wantType; @@ -522,25 +540,7 @@ bool BfGenericInferContext::InferGenericArgument(BfMethodInstance* methodInstanc InferGenericArgument(methodInstance, argInvokeMethod->GetParamType(argIdx), wantInvokeMethod->GetParamType(argIdx), BfIRValue()); } } - } - - if (wantType->IsTuple()) - { - if (argType->IsTuple()) - { - auto wantTupleType = (BfTupleType*)wantType; - auto argTupleType = (BfTupleType*)argType; - - if (wantTupleType->mFieldInstances.size() == argTupleType->mFieldInstances.size()) - { - for (int fieldIdx = 0; fieldIdx < (int)wantTupleType->mFieldInstances.size(); fieldIdx++) - { - InferGenericArgument(methodInstance, argTupleType->mFieldInstances[fieldIdx].mResolvedType, - wantTupleType->mFieldInstances[fieldIdx].mResolvedType, BfIRValue()); - } - } - } - } + } return true; } @@ -18380,11 +18380,6 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExpression* rightExpression, BfBinaryOp binaryOp, BfTokenNode* opToken, BfBinOpFlags flags) { - if ((mModule->mCurMethodInstance != NULL) && (mModule->mCurMethodInstance->mMethodDef->mName == "Angle")) - { - NOP; - } - BfTypedValue leftValue; if (leftExpression != NULL) { diff --git a/IDEHelper/Tests/scripts/Test.txt b/IDEHelper/Tests/scripts/Test.txt new file mode 100644 index 00000000..2568407f --- /dev/null +++ b/IDEHelper/Tests/scripts/Test.txt @@ -0,0 +1,3 @@ +RunTests(true, false) +SelectPlatform("Win64") +RunTests(true, false) diff --git a/bin/test_ide.bat b/bin/test_ide.bat index 8aa1c6cd..54af0c30 100644 --- a/bin/test_ide.bat +++ b/bin/test_ide.bat @@ -11,6 +11,10 @@ SETLOCAL EnableDelayedExpansion PUSHD %~dp0..\ +@ECHO Testing IDEHelper\Tests\Test.txt in BeefIDE_d +%~dp0\RunAndWait %~dp0..\IDE\dist\BeefIDE_d.exe -platform=Win32 -proddir=%~dp0..\IDEHelper\Tests%TESTPATH% -test=scripts\Test.txt +@IF !ERRORLEVEL! NEQ 0 GOTO:EOF + @SET TESTPATH=IDE\Tests\CompileFail001 @CALL :TEST @IF !ERRORLEVEL! NEQ 0 GOTO HADERROR