Add test case for #307

This commit is contained in:
Daniel Holle 2024-03-26 11:04:03 +01:00
parent 606ce8b82d
commit 62f2e05f35
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,44 @@
public class Bug307 {
public void main() {
IVisitor v = new Visitor();
Impl2 f = new Impl2();
f.accept(v);
}
}
interface IVisitor {
void visit(Impl1 f);
void visit(Impl2 fb);
}
interface IAcceptor {
void accept(IVisitor v);
}
class Visitor implements IVisitor {
@Override
public void visit(Impl1 f) {
}
@Override
public void visit(Impl2 fb) {
}
}
class Impl1 implements IAcceptor {
@Override
public void accept(IVisitor v) {
v.visit(this);
}
}
class Impl2 implements IAcceptor {
@Override
public void accept(IVisitor v) {
v.visit(this);
}
}

View File

@ -1022,4 +1022,12 @@ public class TestComplete {
var clazz = classFiles.get("Bug306");
var instance = clazz.getDeclaredConstructor().newInstance();
}
@Test
public void testBug307() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug307.jav");
var clazz = classFiles.get("Bug307");
var instance = clazz.getDeclaredConstructor().newInstance();
clazz.getDeclaredMethod("main").invoke(instance);
}
}