[FIR] Add rendering for attribites of cone types
This commit is contained in:
+4
-4
@@ -4,16 +4,16 @@ FILE: nestedExtensionFunctionType.kt
|
||||
public final fun test_0(a: R|A|, f: R|A.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
|
||||
}
|
||||
public final fun test_1(a: R|A|, ys: R|kotlin/collections/List<kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>| = R|<local>/ys|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>|>|()
|
||||
public final fun test_1(a: R|A|, ys: R|kotlin/collections/List<@ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/Iterator<@ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>>| = R|<local>/ys|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<@ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>>|>|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval y: R|(A) -> kotlin/Unit| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|(A) -> kotlin/Unit|>|()
|
||||
R|<local>/y|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test_2(a: R|A|, vararg zs: @R|kotlin/ExtensionFunctionType|() R|kotlin/Array<out kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>| = R|<local>/zs|.R|FakeOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<CapturedType(out kotlin/Function1<A, kotlin/Unit>)>|>|()
|
||||
public final fun test_2(a: R|A|, vararg zs: @R|kotlin/ExtensionFunctionType|() R|kotlin/Array<out @ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/Iterator<@ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>>| = R|<local>/zs|.R|FakeOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<CapturedType(out @ExtensionFunctionType kotlin/Function1<A, kotlin/Unit>)>|>|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval z: R|(A) -> kotlin/Unit| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|(A) -> kotlin/Unit|>|()
|
||||
R|<local>/z|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
|
||||
|
||||
@@ -19,6 +19,8 @@ object CompilerConeAttributes {
|
||||
override fun isSubtypeOf(other: Exact?): Boolean = true
|
||||
|
||||
override val key: KClass<out Exact> = Exact::class
|
||||
|
||||
override fun toString(): String = "@Exact"
|
||||
}
|
||||
|
||||
object NoInfer : ConeAttribute<NoInfer>() {
|
||||
@@ -29,6 +31,8 @@ object CompilerConeAttributes {
|
||||
override fun isSubtypeOf(other: NoInfer?): Boolean = true
|
||||
|
||||
override val key: KClass<out NoInfer> = NoInfer::class
|
||||
|
||||
override fun toString(): String = "@NoInfer"
|
||||
}
|
||||
|
||||
object ExtensionFunctionType : ConeAttribute<ExtensionFunctionType>() {
|
||||
@@ -39,6 +43,8 @@ object CompilerConeAttributes {
|
||||
override fun isSubtypeOf(other: ExtensionFunctionType?): Boolean = true
|
||||
|
||||
override val key: KClass<out ExtensionFunctionType> = ExtensionFunctionType::class
|
||||
|
||||
override fun toString(): String = "@ExtensionFunctionType"
|
||||
}
|
||||
|
||||
object UnsafeVariance : ConeAttribute<UnsafeVariance>() {
|
||||
@@ -49,6 +55,8 @@ object CompilerConeAttributes {
|
||||
override fun isSubtypeOf(other: UnsafeVariance?): Boolean = true
|
||||
|
||||
override val key: KClass<out UnsafeVariance> = UnsafeVariance::class
|
||||
|
||||
override fun toString(): String = "@UnsafeVariance"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@ abstract class ConeAttribute<T : ConeAttribute<T>> {
|
||||
abstract fun intersect(other: @UnsafeVariance T?): T?
|
||||
abstract fun isSubtypeOf(other: @UnsafeVariance T?): Boolean
|
||||
|
||||
abstract override fun toString(): String
|
||||
|
||||
abstract val key: KClass<out T>
|
||||
}
|
||||
|
||||
@OptIn(Protected::class)
|
||||
class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : AttributeArrayOwner<ConeAttribute<*>, ConeAttribute<*>>() {
|
||||
class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : AttributeArrayOwner<ConeAttribute<*>, ConeAttribute<*>>(),
|
||||
Iterable<ConeAttribute<*>> {
|
||||
|
||||
companion object : TypeRegistry<ConeAttribute<*>, ConeAttribute<*>>() {
|
||||
inline fun <reified T : ConeAttribute<T>> attributeAccessor(): ReadOnlyProperty<ConeAttributes, T?> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -54,6 +58,10 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
|
||||
return perform(other) { this.intersect(it) }
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<ConeAttribute<*>> {
|
||||
return arrayMap.iterator()
|
||||
}
|
||||
|
||||
private inline fun perform(other: ConeAttributes, op: ConeAttribute<*>.(ConeAttribute<*>?) -> ConeAttribute<*>?): ConeAttributes {
|
||||
if (this.isEmpty() && other.isEmpty()) return this
|
||||
val attributes = mutableListOf<ConeAttribute<*>>()
|
||||
|
||||
@@ -12,12 +12,13 @@ import kotlin.contracts.contract
|
||||
fun ConeKotlinType.render(): String {
|
||||
val nullabilitySuffix = if (this !is ConeKotlinErrorType && this !is ConeClassErrorType) nullability.suffix else ""
|
||||
return when (this) {
|
||||
is ConeTypeVariableType -> "TypeVariable(${this.lookupTag.name})"
|
||||
is ConeTypeVariableType -> "${renderAttributes()}TypeVariable(${this.lookupTag.name})"
|
||||
is ConeDefinitelyNotNullType -> "${original.render()}!!"
|
||||
is ConeClassErrorType -> "ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeCapturedType -> "CapturedType(${constructor.projection.render()})"
|
||||
is ConeClassErrorType -> "${renderAttributes()}ERROR CLASS: ${diagnostic.reason}"
|
||||
is ConeCapturedType -> "${renderAttributes()}CapturedType(${constructor.projection.render()})"
|
||||
is ConeClassLikeType -> {
|
||||
buildString {
|
||||
append(renderAttributes())
|
||||
append(lookupTag.classId.asString())
|
||||
if (typeArguments.isNotEmpty()) {
|
||||
append(typeArguments.joinToString(prefix = "<", postfix = ">") {
|
||||
@@ -27,7 +28,7 @@ fun ConeKotlinType.render(): String {
|
||||
}
|
||||
}
|
||||
is ConeLookupTagBasedType -> {
|
||||
lookupTag.name.asString()
|
||||
"${renderAttributes()}${lookupTag.name.asString()}"
|
||||
}
|
||||
is ConeFlexibleType -> {
|
||||
buildString {
|
||||
@@ -41,15 +42,20 @@ fun ConeKotlinType.render(): String {
|
||||
is ConeIntersectionType -> {
|
||||
intersectedTypes.joinToString(
|
||||
separator = " & ",
|
||||
prefix = "it(",
|
||||
prefix = "${renderAttributes()}it(",
|
||||
postfix = ")"
|
||||
)
|
||||
}
|
||||
is ConeStubType -> "Stub: $variable"
|
||||
is ConeIntegerLiteralType -> "ILT: $value"
|
||||
is ConeStubType -> "${renderAttributes()}Stub: $variable"
|
||||
is ConeIntegerLiteralType -> "${renderAttributes()}ILT: $value"
|
||||
} + nullabilitySuffix
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.renderAttributes(): String {
|
||||
if (!attributes.any()) return ""
|
||||
return attributes.joinToString(" ", postfix = " ") { it.toString() }
|
||||
}
|
||||
|
||||
private fun ConeTypeProjection.render(): String {
|
||||
return when (this) {
|
||||
ConeStarProjection -> "*"
|
||||
|
||||
Reference in New Issue
Block a user