Support top level wildcard types
#EA-73650 Fixed
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
// FILE: JavaClass.java
|
||||||
|
public class JavaClass {
|
||||||
|
public void foo(? x) {}
|
||||||
|
|
||||||
|
public void bar(? extends String y) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun foo() {
|
||||||
|
JavaClass().foo(Any())
|
||||||
|
JavaClass().bar(<!TYPE_MISMATCH!>Any()<!>)
|
||||||
|
JavaClass().bar("")
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun foo(): kotlin.Unit
|
||||||
|
|
||||||
|
public open class JavaClass {
|
||||||
|
public constructor JavaClass()
|
||||||
|
public open fun bar(/*0*/ y: kotlin.String!): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun foo(/*0*/ x: kotlin.Any?): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -6873,6 +6873,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("wildcardInValueParameter.kt")
|
||||||
|
public void testWildcardInValueParameter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/wildcardInValueParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/generics/capturedParameters")
|
@TestMetadata("compiler/testData/diagnostics/tests/generics/capturedParameters")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+2
@@ -61,6 +61,8 @@ class LazyJavaTypeResolver(
|
|||||||
)
|
)
|
||||||
else LazyJavaClassifierType(javaType, attr)
|
else LazyJavaClassifierType(javaType, attr)
|
||||||
is JavaArrayType -> transformArrayType(javaType, attr)
|
is JavaArrayType -> transformArrayType(javaType, attr)
|
||||||
|
// Top level type can be a wildcard only in case of broken Java code, but we should not fail with exceptions in such cases
|
||||||
|
is JavaWildcardType -> javaType.bound?.let { transformJavaType(it, attr) } ?: c.module.builtIns.defaultBound
|
||||||
else -> throw UnsupportedOperationException("Unsupported type: " + javaType)
|
else -> throw UnsupportedOperationException("Unsupported type: " + javaType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user