Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1b9766a53 | ||
|
|
35e8dda6bd | ||
|
|
bf22cf246e |
No files matched your search
@@ -0,0 +1,9 @@
|
||||
import java.lang.Integer;
|
||||
sealed interface L<T> permits Cons, Nil {}
|
||||
public record Cons<T>(T head, L<T> tail) implements L<T> {}
|
||||
public record Nil<T>() implements L<T> {}
|
||||
|
||||
public class Bug416 {
|
||||
public static <T> len(Cons(h, t)) { return 1 + len(t); }
|
||||
public static <T> len(Nil()) { return 0; }
|
||||
}
|
||||
@@ -1780,7 +1780,7 @@ public class Codegen {
|
||||
if (parent != null) {
|
||||
state.scope.parent = parent.scope;
|
||||
}
|
||||
var offset = 1;
|
||||
var offset = method.isStatic() ? 0 : 1;
|
||||
for (var param : method.signature().parameters()) {
|
||||
state.createVariable(param.pattern().name(), param.pattern().type());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.lang.classfile.Opcode;
|
||||
import java.lang.reflect.AccessFlag;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -630,7 +631,7 @@ public class ASTToTargetAST {
|
||||
mParams,
|
||||
classType,
|
||||
method.name(),
|
||||
false, false, method.isPrivate()
|
||||
method.isStatic(), false, method.isPrivate()
|
||||
);
|
||||
if (method.signature().returnType() != null) {
|
||||
caseBody = new TargetReturn(caseBody);
|
||||
|
||||
@@ -1775,4 +1775,21 @@ public class TestComplete {
|
||||
assertEquals(10, m.invoke(instance, 1));
|
||||
assertEquals(20, m.invoke(instance, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug416() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug416.jav");
|
||||
var clazz = classFiles.get("Bug416");
|
||||
var L = classFiles.get("L");
|
||||
var Cons = classFiles.get("Cons");
|
||||
var Nil = classFiles.get("Nil");
|
||||
|
||||
var consCtor = Cons.getDeclaredConstructor(Object.class, L);
|
||||
var nilCtor = Nil.getDeclaredConstructor();
|
||||
|
||||
var list = consCtor.newInstance(1, consCtor.newInstance(2, consCtor.newInstance(3, nilCtor.newInstance())));
|
||||
|
||||
var len = clazz.getDeclaredMethod("len", L);
|
||||
assertEquals(3, len.invoke(null, list));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user