[FIR] Add flexible default upper bound for java type parameters
This commit is contained in:
+2
-2
@@ -6,9 +6,9 @@ public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A|
|
||||
|
||||
}
|
||||
public open class B<T> : R|kotlin/Any| {
|
||||
public open class B<T : R|ft<kotlin/Any, kotlin/Any?>!|> : R|kotlin/Any| {
|
||||
public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() t: R|ft<T, T?>!| = Null(null)): R|kotlin/Unit|
|
||||
|
||||
public constructor<T>(): R|B<T>|
|
||||
public constructor<T : R|ft<kotlin/Any, kotlin/Any?>!|>(): R|B<T>|
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class JavaSymbolProvider(
|
||||
forTypeParameterBounds = true
|
||||
)
|
||||
}
|
||||
addDefaultBoundIfNecessary()
|
||||
addDefaultBoundIfNecessary(isFlexible = true)
|
||||
}
|
||||
|
||||
private fun List<JavaTypeParameter>.convertTypeParameters(stack: JavaTypeParameterStack): List<FirTypeParameter> {
|
||||
|
||||
@@ -12,11 +12,21 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.ConeFlexibleType
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
|
||||
fun FirTypeParameterBuilder.addDefaultBoundIfNecessary() {
|
||||
fun FirTypeParameterBuilder.addDefaultBoundIfNecessary(isFlexible: Boolean = false) {
|
||||
if (bounds.isEmpty()) {
|
||||
bounds += session.builtinTypes.nullableAnyType
|
||||
val type = if (isFlexible) {
|
||||
val session = this.session
|
||||
buildResolvedTypeRef {
|
||||
type = ConeFlexibleType(session.builtinTypes.anyType.type, session.builtinTypes.nullableAnyType.type)
|
||||
}
|
||||
} else {
|
||||
session.builtinTypes.nullableAnyType
|
||||
}
|
||||
bounds += type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user