JVM IR: perform substitution in IrTypeSystemContext.getSubstitutedUnderlyingType
This commit is contained in:
@@ -288,9 +288,18 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
|||||||
} ?: owner.superTypes.first()
|
} ?: owner.superTypes.first()
|
||||||
|
|
||||||
override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? {
|
override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? {
|
||||||
// Code in inlineClassesUtils.kt loads the property with the same name and takes its type. This should have the same effect.
|
// Code in inlineClassesUtils.kt loads the property with the same name from the scope of the substituted type and takes its type.
|
||||||
val irClass = (this as? IrType)?.classOrNull?.owner ?: return null
|
// This code below should have the same effect.
|
||||||
return irClass.primaryConstructor?.valueParameters?.singleOrNull()?.type
|
val irClass = (this as? IrType)?.classOrNull?.owner?.takeIf { it.isInline } ?: return null
|
||||||
|
val inlineClassParameter = irClass.primaryConstructor?.valueParameters?.singleOrNull()
|
||||||
|
return inlineClassParameter?.let { parameter ->
|
||||||
|
// Taking only the type parameters of the class (and not its outer classes) is OK since inner classes are always top level
|
||||||
|
IrTypeSubstitutor(
|
||||||
|
irClass.typeParameters.map { it.symbol },
|
||||||
|
(this as? IrSimpleType)?.arguments.orEmpty(),
|
||||||
|
irBuiltIns
|
||||||
|
).substitute(parameter.type)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun TypeConstructorMarker.getPrimitiveType(): PrimitiveType? {
|
override fun TypeConstructorMarker.getPrimitiveType(): PrimitiveType? {
|
||||||
|
|||||||
Vendored
-1
@@ -1,5 +1,4 @@
|
|||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
|
|
||||||
@Suppress("INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE")
|
@Suppress("INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE")
|
||||||
inline class NonNull<T : Any>(val x: T)
|
inline class NonNull<T : Any>(val x: T)
|
||||||
|
|||||||
Reference in New Issue
Block a user