Skip to content

Commit

Permalink
+ regression tests for related bugs fixed "recently"
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-herrmann committed Apr 9, 2024
1 parent 4e5b9e0 commit 051b2fd
Showing 1 changed file with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10710,4 +10710,111 @@ <E extends Fish> Shark<E> fish2() {
"""
});
}

public void testBug569231() {
runConformTest(
new String[] {
"GenericsBug.java",
"""
import java.util.function.Function;
import java.util.function.Predicate;
public class GenericsBug<S> {
public static interface MyInterface<U> {}
public static class SubClass<U,V> implements MyInterface<V>{
public SubClass(Function<U,V> g, MyInterface<V>... i) { }
}
public static class OptSubClass<U> implements MyInterface<U> {
public OptSubClass(String s, Predicate<U> p, MyInterface<U>... i) { }
}
public static class ParamClass<T> {
public T getU() { return null;}
}
GenericsBug(MyInterface<S> in1, MyInterface<S> in2) { }
public static class MySubClass extends SubClass<ParamClass<Boolean>,Boolean> {
public MySubClass() {
super(ParamClass::getU);
}
}
public static void foo() {
SubClass<ParamClass<Boolean>,Boolean> sc = new SubClass<>(ParamClass::getU);
new GenericsBug<>(new MySubClass(),
new OptSubClass<>("foo", t->t, sc));
}
};
"""
});
}

public void testBug566989() {
runConformTest(
new String[] {
"InferTypeTest.java",
"""
import java.util.*;
public class InferTypeTest<T> {
@FunctionalInterface
interface DataLoader<T> {
List<T> loadData(int offset, int limit);
}
class DataList<T> extends ArrayList<T>{
public DataList(DataLoader<T> dataLoader) {
}
}
void testDataList() {
List<String> list = new ArrayList<>(new DataList<>((offset, limit) -> Collections.emptyList()));
}
}
"""
});
}

public void testBug509848() {
runConformTest(
new String[] {
"Generics.java",
"""
public class Generics {
public MyGeneric<?> test() {
boolean maybe = false;
return lambda((String result) -> {
if (maybe) {
return new MyGeneric<>(MyGeneric.of(null));
}
else {
return new MyGeneric<>(MyGeneric.of(""));
}
});
}
static class MyGeneric <T> {
T t;
public MyGeneric(MyGeneric<T> t) {
}
public static <R> MyGeneric<R> of(R t) {
return null;
}
}
public <R> MyGeneric<R> lambda(java.util.function.Function<String, MyGeneric<R>> mapper) {
return null;
}
}
"""
});
}
}

0 comments on commit 051b2fd

Please sign in to comment.