IR: undeprecate IrUninitializedType
It's no longer a temporary hack, see the comment.
This commit is contained in:
+2
-2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.expressions.IrBody
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
@@ -51,9 +52,8 @@ class IrConstructorImpl(
|
|||||||
override lateinit var parent: IrDeclarationParent
|
override lateinit var parent: IrDeclarationParent
|
||||||
override var annotations: List<IrConstructorCall> = emptyList()
|
override var annotations: List<IrConstructorCall> = emptyList()
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
override var returnType: IrType = returnType
|
override var returnType: IrType = returnType
|
||||||
get() = if (field === org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) {
|
get() = if (field === IrUninitializedType) {
|
||||||
error("Return type is not initialized")
|
error("Return type is not initialized")
|
||||||
} else {
|
} else {
|
||||||
field
|
field
|
||||||
|
|||||||
+2
-2
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
@@ -41,9 +42,8 @@ abstract class IrFunctionCommonImpl(
|
|||||||
override lateinit var parent: IrDeclarationParent
|
override lateinit var parent: IrDeclarationParent
|
||||||
override var annotations: List<IrConstructorCall> = emptyList()
|
override var annotations: List<IrConstructorCall> = emptyList()
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
override var returnType: IrType = returnType
|
override var returnType: IrType = returnType
|
||||||
get() = if (field === org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) {
|
get() = if (field === IrUninitializedType) {
|
||||||
error("Return type is not initialized")
|
error("Return type is not initialized")
|
||||||
} else {
|
} else {
|
||||||
field
|
field
|
||||||
|
|||||||
+2
-2
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.IrBody
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
@@ -70,10 +71,9 @@ internal class PersistentIrConstructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
override var returnType: IrType
|
override var returnType: IrType
|
||||||
get() = returnTypeField.let {
|
get() = returnTypeField.let {
|
||||||
if (it !== org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) it else error("Return type is not initialized")
|
if (it !== IrUninitializedType) it else error("Return type is not initialized")
|
||||||
}
|
}
|
||||||
set(c) {
|
set(c) {
|
||||||
returnTypeField = c
|
returnTypeField = c
|
||||||
|
|||||||
+2
-2
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
|
|
||||||
@@ -60,10 +61,9 @@ internal abstract class PersistentIrFunctionCommon(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
final override var returnType: IrType
|
final override var returnType: IrType
|
||||||
get() = returnTypeField.let {
|
get() = returnTypeField.let {
|
||||||
if (it !== org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) it else error("Return type is not initialized")
|
if (it !== IrUninitializedType) it else error("Return type is not initialized")
|
||||||
}
|
}
|
||||||
set(c) {
|
set(c) {
|
||||||
returnTypeField = c
|
returnTypeField = c
|
||||||
|
|||||||
@@ -46,7 +46,16 @@ object IrStarProjectionImpl : IrStarProjection {
|
|||||||
override fun hashCode(): Int = System.identityHashCode(this)
|
override fun hashCode(): Int = System.identityHashCode(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Hack to temporary cover late type initialization")
|
/**
|
||||||
|
* An instance which should be used when creating an IR element whose type cannot be determined at the moment of creation.
|
||||||
|
*
|
||||||
|
* Example: when translating generic functions in psi2ir, we're creating an IrFunction first, then adding IrTypeParameter instances to it,
|
||||||
|
* and only then translating the function's return type with respect to those created type parameters.
|
||||||
|
*
|
||||||
|
* Instead of using this special instance, we could just make IrFunction/IrConstructor constructors allow to accept no return type,
|
||||||
|
* however this could lead to a situation where we forget to set return type sometimes. This would result in crashes at unexpected moments,
|
||||||
|
* especially in Kotlin/JS where function return types are not present in the resulting binary files.
|
||||||
|
*/
|
||||||
object IrUninitializedType : IrType {
|
object IrUninitializedType : IrType {
|
||||||
override val annotations: List<IrConstructorCall> = emptyList()
|
override val annotations: List<IrConstructorCall> = emptyList()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user