[IR] Call IR declaration constructors with named parameters
When those classes become auto-generated, the order of constructor parameters will differ. This commit ensures they will still be resolved correctly. ^KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
a005f2e75d
commit
92ff782815
+10
-3
@@ -296,9 +296,16 @@ class Fir2IrDeclarationStorage(
|
|||||||
name: Name,
|
name: Name,
|
||||||
source: SourceElement,
|
source: SourceElement,
|
||||||
) : IrClassImpl(
|
) : IrClassImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, IrClassSymbolImpl(), name,
|
startOffset = UNDEFINED_OFFSET,
|
||||||
ClassKind.CLASS, DescriptorVisibilities.PUBLIC, Modality.FINAL,
|
endOffset = UNDEFINED_OFFSET,
|
||||||
source, IrFactoryImpl,
|
origin = origin,
|
||||||
|
symbol = IrClassSymbolImpl(),
|
||||||
|
name = name,
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
visibility = DescriptorVisibilities.PUBLIC,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
source = source,
|
||||||
|
factory = IrFactoryImpl,
|
||||||
)
|
)
|
||||||
|
|
||||||
private class NonCachedSourceFacadeContainerSource(
|
private class NonCachedSourceFacadeContainerSource(
|
||||||
|
|||||||
@@ -23,9 +23,16 @@ class JvmFileFacadeClass(
|
|||||||
source: SourceElement,
|
source: SourceElement,
|
||||||
private val deserializeIr: (IrClass) -> Boolean,
|
private val deserializeIr: (IrClass) -> Boolean,
|
||||||
) : IrClassImpl(
|
) : IrClassImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin,
|
startOffset = UNDEFINED_OFFSET,
|
||||||
IrClassSymbolImpl(), name, ClassKind.CLASS, DescriptorVisibilities.PUBLIC, Modality.FINAL,
|
endOffset = UNDEFINED_OFFSET,
|
||||||
source, IrFactoryImpl
|
origin = origin,
|
||||||
|
symbol = IrClassSymbolImpl(),
|
||||||
|
name = name,
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
visibility = DescriptorVisibilities.PUBLIC,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
source = source,
|
||||||
|
factory = IrFactoryImpl
|
||||||
), DeserializableClass {
|
), DeserializableClass {
|
||||||
|
|
||||||
private var irLoaded: Boolean? = null
|
private var irLoaded: Boolean? = null
|
||||||
|
|||||||
+143
-20
@@ -34,7 +34,14 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
symbol: IrAnonymousInitializerSymbol,
|
symbol: IrAnonymousInitializerSymbol,
|
||||||
isStatic: Boolean,
|
isStatic: Boolean,
|
||||||
): IrAnonymousInitializer =
|
): IrAnonymousInitializer =
|
||||||
IrAnonymousInitializerImpl(startOffset, endOffset, origin, symbol, isStatic, factory = this)
|
IrAnonymousInitializerImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
isStatic = isStatic,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createClass(
|
override fun createClass(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -56,7 +63,15 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
source: SourceElement,
|
source: SourceElement,
|
||||||
): IrClass =
|
): IrClass =
|
||||||
IrClassImpl(
|
IrClassImpl(
|
||||||
startOffset, endOffset, origin, symbol, name, kind, visibility, modality, source,
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
kind = kind,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
source = source,
|
||||||
factory = this
|
factory = this
|
||||||
).apply {
|
).apply {
|
||||||
this.isCompanion = isCompanion
|
this.isCompanion = isCompanion
|
||||||
@@ -84,8 +99,18 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
containerSource: DeserializedContainerSource?,
|
containerSource: DeserializedContainerSource?,
|
||||||
): IrConstructor =
|
): IrConstructor =
|
||||||
IrConstructorImpl(
|
IrConstructorImpl(
|
||||||
startOffset, endOffset, origin, symbol, name, visibility, isInline, isExternal, isPrimary, isExpect,
|
startOffset = startOffset,
|
||||||
containerSource, factory = this
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
visibility = visibility,
|
||||||
|
isInline = isInline,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isPrimary = isPrimary,
|
||||||
|
isExpect = isExpect,
|
||||||
|
containerSource = containerSource,
|
||||||
|
factory = this
|
||||||
).apply {
|
).apply {
|
||||||
if (returnType != IrUninitializedType) {
|
if (returnType != IrUninitializedType) {
|
||||||
this.returnType = returnType
|
this.returnType = returnType
|
||||||
@@ -99,14 +124,26 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
name: Name,
|
name: Name,
|
||||||
symbol: IrEnumEntrySymbol,
|
symbol: IrEnumEntrySymbol,
|
||||||
): IrEnumEntry =
|
): IrEnumEntry =
|
||||||
IrEnumEntryImpl(startOffset, endOffset, origin, symbol, name, factory = this)
|
IrEnumEntryImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createErrorDeclaration(
|
override fun createErrorDeclaration(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
descriptor: DeclarationDescriptor?,
|
descriptor: DeclarationDescriptor?,
|
||||||
): IrErrorDeclaration =
|
): IrErrorDeclaration =
|
||||||
IrErrorDeclarationImpl(startOffset, endOffset, descriptor, factory = this)
|
IrErrorDeclarationImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
_descriptor = descriptor,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createField(
|
override fun createField(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -120,7 +157,19 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
isStatic: Boolean,
|
isStatic: Boolean,
|
||||||
isExternal: Boolean,
|
isExternal: Boolean,
|
||||||
): IrField =
|
): IrField =
|
||||||
IrFieldImpl(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic, factory = this)
|
IrFieldImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
type = type,
|
||||||
|
visibility = visibility,
|
||||||
|
isFinal = isFinal,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isStatic = isStatic,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createSimpleFunction(
|
override fun createSimpleFunction(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -142,9 +191,23 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
isFakeOverride: Boolean,
|
isFakeOverride: Boolean,
|
||||||
): IrSimpleFunction =
|
): IrSimpleFunction =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
startOffset, endOffset, origin, symbol, name, visibility, modality,
|
startOffset = startOffset,
|
||||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, isFakeOverride,
|
endOffset = endOffset,
|
||||||
containerSource, factory = this
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
isInline = isInline,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isTailrec = isTailrec,
|
||||||
|
isSuspend = isSuspend,
|
||||||
|
isOperator = isOperator,
|
||||||
|
isInfix = isInfix,
|
||||||
|
isExpect = isExpect,
|
||||||
|
isFakeOverride = isFakeOverride,
|
||||||
|
containerSource = containerSource,
|
||||||
|
factory = this
|
||||||
).apply {
|
).apply {
|
||||||
if (returnType != IrUninitializedType) {
|
if (returnType != IrUninitializedType) {
|
||||||
this.returnType = returnType
|
this.returnType = returnType
|
||||||
@@ -199,7 +262,16 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
type: IrType,
|
type: IrType,
|
||||||
isVar: Boolean,
|
isVar: Boolean,
|
||||||
): IrLocalDelegatedProperty =
|
): IrLocalDelegatedProperty =
|
||||||
IrLocalDelegatedPropertyImpl(startOffset, endOffset, origin, symbol, name, type, isVar, factory = this)
|
IrLocalDelegatedPropertyImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
type = type,
|
||||||
|
isVar = isVar,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createProperty(
|
override fun createProperty(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -219,9 +291,22 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
isFakeOverride: Boolean,
|
isFakeOverride: Boolean,
|
||||||
): IrProperty =
|
): IrProperty =
|
||||||
IrPropertyImpl(
|
IrPropertyImpl(
|
||||||
startOffset, endOffset, origin, symbol, name, visibility, modality,
|
startOffset = startOffset,
|
||||||
isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, isFakeOverride,
|
endOffset = endOffset,
|
||||||
containerSource, factory = this
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
visibility = visibility,
|
||||||
|
modality = modality,
|
||||||
|
isVar = isVar,
|
||||||
|
isConst = isConst,
|
||||||
|
isLateinit = isLateinit,
|
||||||
|
isDelegated = isDelegated,
|
||||||
|
isExternal = isExternal,
|
||||||
|
isExpect = isExpect,
|
||||||
|
isFakeOverride = isFakeOverride,
|
||||||
|
containerSource = containerSource,
|
||||||
|
factory = this
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createPropertyWithLateBinding(
|
override fun createPropertyWithLateBinding(
|
||||||
@@ -266,7 +351,17 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
isActual: Boolean,
|
isActual: Boolean,
|
||||||
expandedType: IrType,
|
expandedType: IrType,
|
||||||
): IrTypeAlias =
|
): IrTypeAlias =
|
||||||
IrTypeAliasImpl(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin, factory = this)
|
IrTypeAliasImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
visibility = visibility,
|
||||||
|
expandedType = expandedType,
|
||||||
|
isActual = isActual,
|
||||||
|
origin = origin,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createTypeParameter(
|
override fun createTypeParameter(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -278,7 +373,17 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
index: Int,
|
index: Int,
|
||||||
isReified: Boolean,
|
isReified: Boolean,
|
||||||
): IrTypeParameter =
|
): IrTypeParameter =
|
||||||
IrTypeParameterImpl(startOffset, endOffset, origin, symbol, name, index, isReified, variance, factory = this)
|
IrTypeParameterImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
index = index,
|
||||||
|
isReified = isReified,
|
||||||
|
variance = variance,
|
||||||
|
factory = this
|
||||||
|
)
|
||||||
|
|
||||||
override fun createValueParameter(
|
override fun createValueParameter(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -295,8 +400,19 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
isHidden: Boolean,
|
isHidden: Boolean,
|
||||||
): IrValueParameter =
|
): IrValueParameter =
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
startOffset, endOffset, origin, symbol, name, index, type, varargElementType,
|
startOffset = startOffset,
|
||||||
isCrossinline, isNoinline, isHidden, isAssignable, factory = this
|
endOffset = endOffset,
|
||||||
|
origin = origin,
|
||||||
|
symbol = symbol,
|
||||||
|
name = name,
|
||||||
|
index = index,
|
||||||
|
type = type,
|
||||||
|
varargElementType = varargElementType,
|
||||||
|
isCrossinline = isCrossinline,
|
||||||
|
isNoinline = isNoinline,
|
||||||
|
isHidden = isHidden,
|
||||||
|
isAssignable = isAssignable,
|
||||||
|
factory = this
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun createExpressionBody(
|
override fun createExpressionBody(
|
||||||
@@ -304,11 +420,18 @@ abstract class AbstractIrFactoryImpl : IrFactory {
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
expression: IrExpression,
|
expression: IrExpression,
|
||||||
): IrExpressionBody =
|
): IrExpressionBody =
|
||||||
IrExpressionBodyImpl(startOffset, endOffset, expression)
|
IrExpressionBodyImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset,
|
||||||
|
expression = expression
|
||||||
|
)
|
||||||
|
|
||||||
override fun createBlockBody(
|
override fun createBlockBody(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
): IrBlockBody =
|
): IrBlockBody =
|
||||||
IrBlockBodyImpl(startOffset, endOffset)
|
IrBlockBodyImpl(
|
||||||
|
startOffset = startOffset,
|
||||||
|
endOffset = endOffset
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,16 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
|
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
|
||||||
|
|
||||||
@OptIn(IrImplementationDetail::class)
|
val IrErrorClassImpl: IrClass = IrFactoryImpl.createClass(
|
||||||
val IrErrorClassImpl = IrClassImpl(
|
startOffset = UNDEFINED_OFFSET,
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.ERROR_CLASS, IrClassSymbolImpl(),
|
endOffset = UNDEFINED_OFFSET,
|
||||||
Name.special("<error>"), ClassKind.CLASS, DescriptorVisibilities.DEFAULT_VISIBILITY, Modality.FINAL,
|
origin = IrDeclarationOrigin.ERROR_CLASS,
|
||||||
SourceElement.NO_SOURCE, IrFactoryImpl
|
symbol = IrClassSymbolImpl(),
|
||||||
|
name = Name.special("<error>"),
|
||||||
|
kind = ClassKind.CLASS,
|
||||||
|
visibility = DescriptorVisibilities.DEFAULT_VISIBILITY,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
source = SourceElement.NO_SOURCE,
|
||||||
).apply {
|
).apply {
|
||||||
parent = ErrorFile
|
parent = ErrorFile
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user