Fix #311
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m55s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m55s
This commit is contained in:
parent
da74898f9d
commit
f66b9099f3
10
resources/bytecode/javFiles/Bug311.jav
Normal file
10
resources/bytecode/javFiles/Bug311.jav
Normal file
@ -0,0 +1,10 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Bug311 {
|
||||
Bug311A i = new Bug311A();
|
||||
public toString() {
|
||||
return i.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class Bug311A {}
|
@ -79,8 +79,9 @@ public class ASTToTargetAST {
|
||||
|
||||
Optional<Method> findMethod(ClassOrInterface owner, String name, List<TargetType> argumentList) {
|
||||
Optional<Method> method = Optional.empty();
|
||||
while (method.isEmpty() && !owner.getClassName().toString().equals("java.lang.Object")) {
|
||||
while (method.isEmpty()) {
|
||||
method = owner.getMethods().stream().filter(m -> m.name.equals(name) && parameterEquals(m.getParameterList(), argumentList)).findFirst();
|
||||
if (owner.getClassName().toString().equals("java.lang.Object")) break;
|
||||
owner = compiler.getClass(owner.getSuperClass().getName());
|
||||
}
|
||||
return method;
|
||||
|
@ -1040,6 +1040,14 @@ public class TestComplete {
|
||||
assertEquals(clazz.getDeclaredMethod("toString").invoke(instance), "3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug311() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug311.jav");
|
||||
var clazz = classFiles.get("Bug311");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
clazz.getDeclaredMethod("toString").invoke(instance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug312() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug312.jav");
|
||||
|
Loading…
Reference in New Issue
Block a user