FE: force flexibility on unannotated ?

TODO: unify this code with FIR

 #KT-48515 Fixed
This commit is contained in:
pyos
2021-09-07 11:42:02 +02:00
committed by Victor Petukhov
parent afa1d18cc2
commit 8f699248f1
12 changed files with 169 additions and 0 deletions
@@ -119,6 +119,16 @@ class JavaTypeEnhancement(private val javaResolverSettings: JavaResolverSettings
val enhanced = when {
!shouldEnhanceArguments -> Result(null, 0)
!arg.isStarProjection -> arg.type.unwrap().enhancePossiblyFlexible(qualifiers, globalArgIndex, isSuperTypesEnhancement)
qualifiers(globalArgIndex).nullability == FORCE_FLEXIBILITY ->
arg.type.unwrap().let {
// Given `C<T extends @Nullable V>`, unannotated `C<?>` is `C<out (V..V?)>`.
Result(
KotlinTypeFactory.flexibleType(
it.lowerIfFlexible().makeNullableAsSpecified(false),
it.upperIfFlexible().makeNullableAsSpecified(true)
), 1
)
}
else -> Result(null, 1)
}
globalArgIndex += enhanced.subtreeSize