mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Fixed virtuals defaults issue, added virtuals test
This commit is contained in:
parent
40c404f329
commit
5d1a9e6873
4 changed files with 68 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -4292,6 +4292,16 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV
|
|||
{
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
46
IDEHelper/Tests/src/Virtuals.bf
Normal file
46
IDEHelper/Tests/src/Virtuals.bf
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue