SLC: account for upperbounds when computing nullability of type parameter

This commit is contained in:
Jinseong Jeon
2022-08-28 16:00:24 -07:00
committed by Ilya Kirillov
parent e83819e682
commit 4859524115
2 changed files with 3 additions and 19 deletions
@@ -149,13 +149,9 @@ internal fun KtAnalysisSession.getTypeNullability(ktType: KtType): NullabilityTy
if (ktType.isUnit) return NullabilityType.NotNull
if (ktType is KtTypeParameterType) {
// TODO Make supertype checking
// val subtypeOfNullableSuperType = context.firRef.withFir(phase) {
// it.session.typeCheckerContext.nullableAnyType().isSupertypeOf(it.session.typeCheckerContext, coneType)
// }
// if (!subtypeOfNullableSuperType) return NullabilityType.NotNull
return if (!ktType.isMarkedNullable) NullabilityType.Unknown else NullabilityType.NotNull
if (ktType.isMarkedNullable) return NullabilityType.Nullable
val subtypeOfNullableSuperType = ktType.symbol.upperBounds.all { upperBound -> upperBound.canBeNull }
return if (!subtypeOfNullableSuperType) NullabilityType.NotNull else NullabilityType.Unknown
}
if (ktType !is KtClassType) return NullabilityType.NotNull
@@ -1,12 +0,0 @@
public abstract interface Generic /* Generic*/<N, NN> {
@org.jetbrains.annotations.Nullable()
public abstract N a1(@org.jetbrains.annotations.Nullable() N);// a1(N)
@org.jetbrains.annotations.Nullable()
public abstract NN b1(@org.jetbrains.annotations.Nullable() NN);// b1(NN)
public abstract N a(N);// a(N)
public abstract NN b(NN);// b(NN)
}