KT-6815 Representing raw types when used as supertypes for Java classes
#KT-6815 Fixed
This commit is contained in:
+11
-13
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import kotlin.properties.*
|
||||
|
||||
class LazyJavaTypeResolver(
|
||||
private val c: LazyJavaResolverContext,
|
||||
@@ -89,17 +90,14 @@ class LazyJavaTypeResolver(
|
||||
}.replaceAnnotations(attr.annotations)
|
||||
}
|
||||
|
||||
private class LazyStarProjection(
|
||||
val typeParameter: TypeParameterDescriptor,
|
||||
val attr: JavaTypeAttributes
|
||||
) : TypeProjectionBase() {
|
||||
override fun isStarProjection() = true
|
||||
|
||||
override fun getProjectionKind() =
|
||||
// projections are not allowed in immediate arguments of supertypes
|
||||
if (typeParameter.getVariance() == OUT_VARIANCE || attr.howThisTypeIsUsed == SUPERTYPE) INVARIANT else OUT_VARIANCE
|
||||
|
||||
override fun getType() = typeParameter.getUpperBoundsAsType()
|
||||
fun makeStarProjection(
|
||||
typeParameter: TypeParameterDescriptor,
|
||||
attr: JavaTypeAttributes
|
||||
): TypeProjection {
|
||||
return if (attr.howThisTypeIsUsed == SUPERTYPE)
|
||||
TypeProjectionImpl(typeParameter.starProjectionType())
|
||||
else
|
||||
StarProjectionImpl(typeParameter)
|
||||
}
|
||||
|
||||
private inner class LazyJavaClassifierType(
|
||||
@@ -197,7 +195,7 @@ class LazyJavaTypeResolver(
|
||||
TypeProjectionImpl(projectionKind, KotlinBuiltIns.getInstance().getNullableAnyType())
|
||||
}
|
||||
else
|
||||
LazyStarProjection(parameter, attr)
|
||||
makeStarProjection(parameter, attr)
|
||||
}
|
||||
}
|
||||
if (isConstructorTypeParameter()) {
|
||||
@@ -228,7 +226,7 @@ class LazyJavaTypeResolver(
|
||||
is JavaWildcardType -> {
|
||||
val bound = javaType.getBound()
|
||||
if (bound == null)
|
||||
LazyStarProjection(typeParameter, attr)
|
||||
makeStarProjection(typeParameter, attr)
|
||||
else {
|
||||
var projectionKind = if (javaType.isExtends()) OUT_VARIANCE else IN_VARIANCE
|
||||
if (projectionKind == typeParameter.getVariance()) {
|
||||
|
||||
Reference in New Issue
Block a user