Do not use KotlinTypeMapper in generateTypeOf inline intrinsic
Make ReifiedTypeInliner and related classes generic over the KotlinTypeMarker subtype (KotlinType or IrType), add a typeSystem to get arguments/nullability and other properties of types regardless of their representation, but still fall back to KotlinType when generating the actual bytecode of other intrinsics (as/is)
This commit is contained in:
@@ -12,6 +12,9 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
fun nullableAnyType(): SimpleTypeMarker
|
||||
fun arrayType(componentType: KotlinTypeMarker): SimpleTypeMarker
|
||||
|
||||
fun TypeConstructorMarker.isFinalClassOrEnumEntryOrAnnotationClassConstructor(): Boolean
|
||||
|
||||
fun KotlinTypeMarker.hasAnnotation(fqName: FqName): Boolean
|
||||
@@ -44,6 +47,7 @@ interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
fun TypeConstructorMarker.getClassFqNameUnsafe(): FqNameUnsafe?
|
||||
|
||||
fun TypeParameterMarker.getName(): Name
|
||||
fun TypeParameterMarker.isReified(): Boolean
|
||||
|
||||
fun KotlinTypeMarker.isInterfaceOrAnnotationClass(): Boolean
|
||||
}
|
||||
|
||||
+12
-1
@@ -341,7 +341,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return builtIns.anyType
|
||||
}
|
||||
|
||||
val builtIns: KotlinBuiltIns get() = throw UnsupportedOperationException("Not supported")
|
||||
open val builtIns: KotlinBuiltIns
|
||||
get() = throw UnsupportedOperationException("Not supported")
|
||||
|
||||
override fun KotlinTypeMarker.makeDefinitelyNotNullOrNotNull(): KotlinTypeMarker {
|
||||
require(this is UnwrappedType, this::errorMessage)
|
||||
@@ -502,6 +503,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return this is NewCapturedTypeConstructor
|
||||
}
|
||||
|
||||
override fun arrayType(componentType: KotlinTypeMarker): SimpleTypeMarker {
|
||||
require(componentType is KotlinType, this::errorMessage)
|
||||
return builtIns.getArrayType(Variance.INVARIANT, componentType)
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.hasAnnotation(fqName: FqName): Boolean {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return annotations.hasAnnotation(fqName)
|
||||
@@ -557,6 +563,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return name
|
||||
}
|
||||
|
||||
override fun TypeParameterMarker.isReified(): Boolean {
|
||||
require(this is TypeParameterDescriptor, this::errorMessage)
|
||||
return isReified
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isInterfaceOrAnnotationClass(): Boolean {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
val descriptor = constructor.declarationDescriptor
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.types.checker
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
@@ -31,6 +32,8 @@ import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
|
||||
object SimpleClassicTypeSystemContext : ClassicTypeSystemContext
|
||||
|
||||
class ClassicTypeSystemContextImpl(override val builtIns: KotlinBuiltIns) : ClassicTypeSystemContext
|
||||
|
||||
object StrictEqualityTypeChecker {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user