[IR] Pass null instead of IrUninitializedType to IrFactory

#KT-66053 In progress
This commit is contained in:
Wojciech Litewka
2024-03-05 12:36:53 +01:00
committed by Space Team
parent 1a4eaf796d
commit d1e8016ab2
16 changed files with 54 additions and 55 deletions
@@ -405,7 +405,9 @@ object IrTree : AbstractTreeBuilder() {
// NB: there's an inline constructor for Array and each primitive array class.
+field("isInline", boolean)
+field("isExpect", boolean)
+field("returnType", irTypeType)
+field("returnType", irTypeType) {
useFieldInIrFactory(customType = irTypeType.copy(nullable = true))
}
+field("dispatchReceiverParameter", valueParameter, nullable = true)
+field("extensionReceiverParameter", valueParameter, nullable = true)
+listField("valueParameters", valueParameter, mutability = Var)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -25,8 +25,8 @@ abstract class AbstractTreeBuilder {
customUseInIrFactoryStrategy = Field.UseFieldAsParameterInIrFactoryStrategy.No
}
protected fun Field.useFieldInIrFactory(defaultValue: String? = null) {
customUseInIrFactoryStrategy = Field.UseFieldAsParameterInIrFactoryStrategy.Yes(defaultValue)
protected fun Field.useFieldInIrFactory(customType: TypeRef? = null, defaultValue: String? = null) {
customUseInIrFactoryStrategy = Field.UseFieldAsParameterInIrFactoryStrategy.Yes(customType, defaultValue)
}
fun element(category: Element.Category, name: String? = null, initializer: Element.() -> Unit = {}): ElementDelegate {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -16,7 +16,7 @@ sealed class Field(
data object No : UseFieldAsParameterInIrFactoryStrategy()
data class Yes(val defaultValue: String?) : UseFieldAsParameterInIrFactoryStrategy()
data class Yes(val customType: TypeRef?, val defaultValue: String?) : UseFieldAsParameterInIrFactoryStrategy()
}
var customUseInIrFactoryStrategy: UseFieldAsParameterInIrFactoryStrategy? = null
@@ -26,7 +26,7 @@ sealed class Field(
?: if (isChild && containsElement) {
UseFieldAsParameterInIrFactoryStrategy.No
} else {
UseFieldAsParameterInIrFactoryStrategy.Yes(null)
UseFieldAsParameterInIrFactoryStrategy.Yes(null, null)
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -50,7 +50,7 @@ private class FactoryMethod(val element: Element) {
.filterNot { it.name in element.fieldsToSkipInIrFactoryMethod }
.mapNotNull { field ->
(field.useInIrFactoryStrategy as? Field.UseFieldAsParameterInIrFactoryStrategy.Yes)?.let {
FunctionParameter(field.name, field.typeRef, it.defaultValue)
FunctionParameter(field.name, it.customType ?: field.typeRef, it.defaultValue)
}
}
.sortedBy { it.defaultValue != null } // All parameters with default values must go last