diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 96839ac6..9c51c63f 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -2348,7 +2348,7 @@ namespace IDE switch (err) { case .FormatError(int lineNum): - OutputLineSmart("ERROR: Workspace format error in '{0}' on line {1}", workspaceFileName, lineNum); + OutputErrorLine("Workspace format error in '{0}' on line {1}", workspaceFileName, lineNum); LoadFailed(); return; case .FileError: // Assume 'file not found' @@ -2449,7 +2449,7 @@ namespace IDE { if (mVerb == .New) { - OutputLineSmart("ERROR: Workspace '{0}' already exists, but '-new' argument was specified.", workspaceFileName); + OutputErrorLine("Workspace '{0}' already exists, but '-new' argument was specified.", workspaceFileName); LoadFailed(); } @@ -6653,6 +6653,7 @@ namespace IDE public void OutputErrorLine(String format, params Object[] args) { + ShowOutput(); var errStr = scope String(); errStr.Append("ERROR: ", format); OutputLineSmart(errStr, params args); @@ -8090,7 +8091,7 @@ namespace IDE } else { - OutputLineSmart("ERROR: Project '{0}' has a Test configuration specified but the workspace is not using a Test configuration", project.mProjectName); + OutputErrorLine("Project '{0}' has a Test configuration specified but the workspace is not using a Test configuration", project.mProjectName); success = false; } } @@ -9717,7 +9718,7 @@ namespace IDE { if (workspaceOptions.mBuildKind == .Test) { - OutputLineSmart("ERROR: Cannot directly run Test workspace configurations. Use the 'Test' menu to run or debug tests."); + OutputErrorLine("Cannot directly run Test workspace configurations. Use the 'Test' menu to run or debug tests."); return false; } } @@ -9796,7 +9797,7 @@ namespace IDE if (mDisableBuilding) { - OutputLineSmart("ERROR: Compiling disabled!"); + OutputErrorLine("Compiling disabled!"); return false; } @@ -9887,7 +9888,7 @@ namespace IDE if (mWorkspace.mStartupProject == null) { - OutputLineSmart("ERROR: No startup project started"); + OutputErrorLine("No startup project started"); return false; } var project = mWorkspace.mStartupProject; @@ -9895,7 +9896,7 @@ namespace IDE var options = GetCurProjectOptions(project); if (options == null) { - OutputLineSmart("ERROR: Startup project '{0}' not enabled", mWorkspace.mStartupProject.mProjectName); + OutputErrorLine("Startup project '{0}' not enabled", mWorkspace.mStartupProject.mProjectName); return false; } @@ -10838,7 +10839,7 @@ namespace IDE { if (mHotResolveTryIdx == 0) { - OutputLineSmart("ERROR: Hot type data changes cannot be applied because of the following types"); + OutputErrorLine("ERROR: Hot type data changes cannot be applied because of the following types"); for (var line in hotResult.Split('\n')) { OutputLineSmart(" {0}", line); diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index a0eee3e0..4542945f 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -4289,9 +4289,19 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV } if (methodInstance->mVirtualTableIdx != -1) - { + { if ((!bypassVirtual) && (mDeferCallRef == NULL)) { + if ((methodDef->mIsOverride) && (mModule->mCurMethodInstance->mIsReified)) + { + // Ensure that declaring method gets referenced + auto typeInstance = methodInstance->GetOwner(); + auto& vEntry = typeInstance->mVirtualMethodTable[methodInstance->mVirtualTableIdx]; + BfMethodInstance* declaringMethodInstance = vEntry.mDeclaringMethod; + if ((declaringMethodInstance->mMethodInstanceGroup->mOnDemandKind < BfMethodOnDemandKind_InWorkList) || (!methodInstance->mIsReified)) + mModule->GetMethodInstance(declaringMethodInstance); + } + auto funcType = mModule->mBfIRBuilder->MapMethod(methodInstance); auto funcPtrType1 = mModule->mBfIRBuilder->GetPointerTo(funcType); auto funcPtrType2 = mModule->mBfIRBuilder->GetPointerTo(funcPtrType1); diff --git a/IDEHelper/Tests/src/Reflection.bf b/IDEHelper/Tests/src/Reflection.bf index c5f4aadb..07bb8590 100644 --- a/IDEHelper/Tests/src/Reflection.bf +++ b/IDEHelper/Tests/src/Reflection.bf @@ -101,7 +101,9 @@ namespace Tests static void TestA() { ClassA ca = scope ClassA(); + ClassA2 ca2 = scope ClassA2(); + Test.Assert(ca2.GetA(9) == 2009); int methodIdx = 0; diff --git a/IDEHelper/Tests/src/Virtuals.bf b/IDEHelper/Tests/src/Virtuals.bf new file mode 100644 index 00000000..d6f04c10 --- /dev/null +++ b/IDEHelper/Tests/src/Virtuals.bf @@ -0,0 +1,46 @@ +#pragma warning disable 168 + +using System; + +namespace Tests +{ + class Virtuals + { + class ClassA + { + public virtual int Method0(int a = 111) + { + return a; + } + } + + class ClassB : ClassA + { + public override int Method0(int a = 222) + { + return a + 1000; + } + } + + class ClassC : ClassB + { + public override int Method0(int a) + { + return a + 2000; + } + } + + [Test] + public static void TestBasics() + { + ClassA ca = scope ClassA(); + Test.Assert(ca.Method0() == 111); + + ClassB cb = scope ClassB(); + Test.Assert(cb.Method0() == 1222); + + cb = scope ClassC(); + Test.Assert(cb.Method0() == 2222); + } + } +}