Fix loading Java type arguments
Type arguments with use variance in java contradicting to Kotlin declaration-site variance should be loaded as star-projections #KT-11492 Fixed
This commit is contained in:
+8
-2
@@ -224,12 +224,13 @@ class LazyJavaTypeResolver(
|
||||
return when (javaType) {
|
||||
is JavaWildcardType -> {
|
||||
val bound = javaType.bound
|
||||
if (bound == null)
|
||||
val projectionKind = if (javaType.isExtends) OUT_VARIANCE else IN_VARIANCE
|
||||
if (bound == null || projectionKind.isConflictingArgumentFor(typeParameter))
|
||||
makeStarProjection(typeParameter, attr)
|
||||
else {
|
||||
createProjection(
|
||||
type = transformJavaType(bound, UPPER_BOUND.toAttributes()),
|
||||
projectionKind = if (javaType.isExtends) OUT_VARIANCE else IN_VARIANCE,
|
||||
projectionKind = projectionKind,
|
||||
typeParameterDescriptor = typeParameter
|
||||
)
|
||||
}
|
||||
@@ -238,6 +239,11 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Variance.isConflictingArgumentFor(typeParameter: TypeParameterDescriptor): Boolean {
|
||||
if (typeParameter.variance == INVARIANT) return false
|
||||
return this != typeParameter.variance
|
||||
}
|
||||
|
||||
override fun getCapabilities(): TypeCapabilities = if (isRaw()) RawTypeCapabilities else TypeCapabilities.NONE
|
||||
|
||||
private val nullable = c.storageManager.createLazyValue l@ {
|
||||
|
||||
Reference in New Issue
Block a user