Skip to content

Commit ed79bb8

Browse files
Compilation errors with latest nightly build (eclipse-jdt#3955)
Test for eclipse-jdt#3948
1 parent ca44329 commit ed79bb8

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_9.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
1919
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
2020

21+
/**
22+
* Test class originally capturing issues specific to Java9, but meanwhile also just a continuation
23+
* of GenericsRegressionTest_1_8.
24+
*/
2125
public class GenericsRegressionTest_9 extends AbstractRegressionTest9 {
2226

2327
static {
@@ -1092,6 +1096,57 @@ public static <T> IQuery<T> createCompoundQuery(Collection<? extends IQuery<? ex
10921096
"""
10931097
});
10941098
}
1099+
public void testGH3948() {
1100+
runNegativeTest(new String[] {
1101+
"Foo.java",
1102+
"""
1103+
import java.util.Collections;
1104+
import java.util.List;
1105+
import java.util.function.BiConsumer;
1106+
import java.util.function.Function;
1107+
1108+
public class Foo {
1109+
private List<? extends Bar> value;
1110+
1111+
public void set(List<? extends Bar> value) {
1112+
this.value = value;
1113+
}
1114+
1115+
public List<Bar> get() {
1116+
return Collections.unmodifiableList(value);
1117+
}
1118+
1119+
public static void main(String[] args) {
1120+
test(Foo::get, Foo::set);
1121+
}
1122+
1123+
public static <U> void test(Function<Foo, List<U>> getter, BiConsumer<Foo, List<? extends U>> setter) {
1124+
// noop
1125+
}
1126+
1127+
public static interface Bar{}
1128+
}
1129+
"""
1130+
},
1131+
"""
1132+
----------
1133+
1. ERROR in Foo.java (at line 18)
1134+
test(Foo::get, Foo::set);
1135+
^^^^
1136+
The method test(Function<Foo,List<U>>, BiConsumer<Foo,List<? extends U>>) in the type Foo is not applicable for the arguments (Foo::get, Foo::set)
1137+
----------
1138+
2. ERROR in Foo.java (at line 18)
1139+
test(Foo::get, Foo::set);
1140+
^^^^^^^^
1141+
The type of get() from the type Foo is List<Foo.Bar>, this is incompatible with the descriptor's return type: List<U>
1142+
----------
1143+
3. ERROR in Foo.java (at line 18)
1144+
test(Foo::get, Foo::set);
1145+
^^^^^^^^
1146+
The type Foo does not define set(Foo, List<capture#5-of ? extends U>) that is applicable here
1147+
----------
1148+
""");
1149+
}
10951150
public static Class<GenericsRegressionTest_9> testClass() {
10961151
return GenericsRegressionTest_9.class;
10971152
}

0 commit comments

Comments
 (0)