Fix NPE in generics, probably because interface method don't have code

This commit is contained in:
Daniel Holle 2024-03-15 17:14:27 +01:00
parent 66c8c307b0
commit a1b5c0541b
3 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,13 @@
import java.lang.Integer;
import java.lang.Float;
public class Bug293 {
bar(a) {
return 2 * a;
}
}
interface IFoo {
void ga();
}

View File

@ -753,7 +753,9 @@ public abstract class GenerateGenerics {
}
doIterationForMethods(classOrInterface);
for (var method : classOrInterface.getMethods()) {
referenced.addAll(usedTPHsOfMethods.get(method));
var usedTPHs = usedTPHsOfMethods.get(method);
if (usedTPHs != null)
referenced.addAll(usedTPHs);
}
eliminateInnerTypeVariables(referenced, input);
}

View File

@ -933,4 +933,11 @@ public class TestComplete {
var clazz = classFiles.get("Bug290A");
var instance = clazz.getDeclaredConstructor().newInstance();
}
@Test
public void testBug293() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug293.jav");
var clazz = classFiles.get("Bug293");
var instance = clazz.getDeclaredConstructor().newInstance();
}
}