Skip to content

Commit

Permalink
Add a test to track #461
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 8, 2024
1 parent c14ea43 commit 0f23b36
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/IKVM.Tests/Runtime/DefaultInterfaceMethodTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using FluentAssertions;

using IKVM.Tests.Util;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IKVM.Tests.Runtime
{

[TestClass]
public class DefaultInterfaceMethodTests
{

[TestMethod]
[Ignore]
public void ShouldResolveOverlappingDefaultImplementation()
{
var code = @"
public class TestClass {
public static interface CommandInteractionPayload {
int getValue();
}
public static interface CommandInteraction extends CommandInteractionPayload {
}
public static interface CommandInteractionPayloadMixin extends CommandInteractionPayload {
@Override
default int getValue() {
return 1;
}
}
public static class CommandInteractionImpl implements CommandInteraction, CommandInteractionPayloadMixin {
}
public static interface SlashCommandInteraction extends CommandInteraction {
}
public static class SlashCommandInteractionImpl extends CommandInteractionImpl implements SlashCommandInteraction {
}
}
";
var unit = new InMemoryCodeUnit("TestClass", code);
var compiler = new InMemoryCompiler(new[] { unit });
compiler.Compile();

var clazz = compiler.GetClass("TestClass$SlashCommandInteractionImpl");
var ctor = clazz.getConstructor();
dynamic test = ctor.newInstance(System.Array.Empty<object>());
((int)test.getValue()).Should().Be(1);
}

}

}

0 comments on commit 0f23b36

Please sign in to comment.