Fix null Java type argument problem & add relevant test

This commit is contained in:
Mikhail Glukhikh
2019-03-01 12:10:05 +03:00
parent 7563a98999
commit fb788dc4c0
14 changed files with 52 additions and 18 deletions
@@ -42,7 +42,7 @@ class JavaTypeResolver(
private val typeParameterResolver: TypeParameterResolver
) {
fun transformJavaType(javaType: JavaType, attr: JavaTypeAttributes): KotlinType {
fun transformJavaType(javaType: JavaType?, attr: JavaTypeAttributes): KotlinType {
return when (javaType) {
is JavaPrimitiveType -> {
val primitiveType = javaType.type
@@ -53,6 +53,7 @@ class JavaTypeResolver(
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
null -> c.module.builtIns.defaultBound
else -> throw UnsupportedOperationException("Unsupported type: " + javaType)
}
}
@@ -247,7 +248,7 @@ class JavaTypeResolver(
}
private fun transformToTypeProjection(
javaType: JavaType,
javaType: JavaType?,
attr: JavaTypeAttributes,
typeParameter: TypeParameterDescriptor
): TypeProjection {
@@ -26,7 +26,7 @@ interface JavaArrayType : JavaType {
interface JavaClassifierType : JavaType, JavaAnnotationOwner {
val classifier: JavaClassifier?
val typeArguments: List<JavaType>
val typeArguments: List<JavaType?>
val isRaw: Boolean