Use TypeSystemCommonBackendContext in computeExpandedTypeForInlineClass
This commit is contained in:
@@ -6,9 +6,7 @@
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemContext
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
fun TypeConstructorMarker.isFinalClassOrEnumEntryOrAnnotationClassConstructor(): Boolean
|
||||
@@ -24,4 +22,15 @@ interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
* TODO: provide a more granular & elaborate API here to reduce confusion
|
||||
*/
|
||||
fun KotlinTypeMarker.getAnnotationFirstArgumentValue(fqName: FqName): Any?
|
||||
|
||||
fun TypeConstructorMarker.getTypeParameterClassifier(): TypeParameterMarker?
|
||||
fun TypeConstructorMarker.isInlineClass(): Boolean
|
||||
fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker
|
||||
fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker?
|
||||
|
||||
fun KotlinTypeMarker.isMarkedNullable(): Boolean =
|
||||
this is SimpleTypeMarker && isMarkedNullable()
|
||||
|
||||
fun KotlinTypeMarker.makeNullable(): KotlinTypeMarker =
|
||||
asSimpleType()?.withNullability(true) ?: this
|
||||
}
|
||||
|
||||
@@ -16,10 +16,12 @@ import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasExactAnnotation
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasNoInferAnnotation
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExactAnnotation
|
||||
import org.jetbrains.kotlin.resolve.substitutedUnderlyingType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@@ -495,6 +497,26 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return annotations.findAnnotation(fqName)?.allValueArguments?.values?.firstOrNull()?.value
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.getTypeParameterClassifier(): TypeParameterMarker? {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return declarationDescriptor as? TypeParameterDescriptor
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.isInlineClass(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return (declarationDescriptor as? ClassDescriptor)?.isInline == true
|
||||
}
|
||||
|
||||
override fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker {
|
||||
require(this is TypeParameterDescriptor, this::errorMessage)
|
||||
return representativeUpperBound
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return substitutedUnderlyingType()
|
||||
}
|
||||
}
|
||||
|
||||
fun TypeVariance.convertVariance(): Variance {
|
||||
|
||||
Reference in New Issue
Block a user