-
Bug
-
Resolution: Fixed
-
P3
-
20
-
b27
Consider code like this:
---
public class Test7 {
interface Intf<A> {
}
record Rec<T>(T a) implements Intf<T> {
}
static boolean test(Intf<? super String> p) {
return p instanceof Rec<? super String>(var a);
}
public static void main(String... args) {
boolean res = test(new Rec<>(new Object()));
if (!res) throw new AssertionError();
}
}
---
Compiling this code and running it fails, as the matching fails.
The reason matching fails is that the type of `var a` is determined to be `String`, but should be `Object`.
---
public class Test7 {
interface Intf<A> {
}
record Rec<T>(T a) implements Intf<T> {
}
static boolean test(Intf<? super String> p) {
return p instanceof Rec<? super String>(var a);
}
public static void main(String... args) {
boolean res = test(new Rec<>(new Object()));
if (!res) throw new AssertionError();
}
}
---
Compiling this code and running it fails, as the matching fails.
The reason matching fails is that the type of `var a` is determined to be `String`, but should be `Object`.