New J2K: Add JKType.updateNullability function

This commit is contained in:
Ilya Kirillov
2018-11-10 19:26:57 +03:00
committed by Ilya Kirillov
parent 2e0c7e9128
commit 3771ccedb7
@@ -135,3 +135,15 @@ fun JKClassSymbol.toKtType(symbolProvider: JKSymbolProvider): KotlinType {
}
return classDescriptor.defaultType
}
fun JKType.updateNullability(newNullability: Nullability): JKType =
if (nullability == newNullability) this
else when (this) {
is JKTypeParameterTypeImpl -> JKTypeParameterTypeImpl(name, newNullability)
is JKClassTypeImpl -> JKClassTypeImpl(classReference, parameters, newNullability)
is JKUnresolvedClassType -> JKUnresolvedClassType(name, parameters, newNullability)
is JKNoType -> this
is JKJavaVoidType -> this
is JKJavaPrimitiveType -> this
else -> TODO(this::class.toString())
}