From 62f2e05f35b87e41917a598be08353901b332c64 Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Tue, 26 Mar 2024 11:04:03 +0100 Subject: [PATCH] Add test case for #307 --- resources/bytecode/javFiles/Bug307.jav | 44 ++++++++++++++++++++++++++ src/test/java/TestComplete.java | 8 +++++ 2 files changed, 52 insertions(+) create mode 100644 resources/bytecode/javFiles/Bug307.jav diff --git a/resources/bytecode/javFiles/Bug307.jav b/resources/bytecode/javFiles/Bug307.jav new file mode 100644 index 00000000..48b2b4e1 --- /dev/null +++ b/resources/bytecode/javFiles/Bug307.jav @@ -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); + } +} diff --git a/src/test/java/TestComplete.java b/src/test/java/TestComplete.java index ebc973cf..707762cd 100644 --- a/src/test/java/TestComplete.java +++ b/src/test/java/TestComplete.java @@ -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); + } }