mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 06:21:25 +07:00
java type system: use captured wildcard bounds in cast context (IDEA-233551)
starting with javac 1.9+ such code starting to compile, javac 8 rejects the code with the same language level used GitOrigin-RevId: 87a1e4d475927af0ee71cd74f5a66e130908ed82
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ef5f5bafa1
commit
022c5be762
@@ -120,6 +120,7 @@ public class TypeConversionUtil {
|
||||
// 5.5. Casting Contexts
|
||||
if ((fromTypeRank == SHORT_RANK || fromTypeRank == BYTE_RANK) && toTypeRank == CHAR_RANK) return false;
|
||||
|
||||
fromType = uncapture(fromType); //starting from javac 9+
|
||||
if (fromType instanceof PsiClassType) {
|
||||
if (languageLevel == null) {
|
||||
languageLevel = ((PsiClassType)fromType).getLanguageLevel();
|
||||
|
||||
@@ -30,6 +30,6 @@ class Foo<T> {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Foo<?> foo = getFoo();
|
||||
double value = <error descr="Inconvertible types; cannot cast 'capture<?>' to 'double'">(double) foo.getValue()</error>;
|
||||
double value = (double) foo.getValue();
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,6 @@ class Foo<T> {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Foo<?> foo = getFoo();
|
||||
double value = <error descr="Inconvertible types; cannot cast 'capture<?>' to 'double'">(double) foo.getValue()</error>;
|
||||
double value = (double) foo.getValue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user