From 54078c4e9c33ea8afaaf81de7067247cc6d5eb22 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 27 May 2019 17:46:49 +0300 Subject: [PATCH] FIR resolve: support inferring property type from getter --- .../transformers/FirBodyResolveTransformer.kt | 119 ++++++++++++------ .../testData/resolve/typeFromGetter.kt | 12 ++ .../testData/resolve/typeFromGetter.txt | 24 ++++ .../fir/FirResolveTestCaseGenerated.java | 5 + .../classLiteralInAnnotation.fir.txt | 8 +- .../declarations/extensionProperties.fir.txt | 24 ++-- .../localClassWithOverrides.fir.txt | 8 +- .../parameters/propertyAccessors.fir.txt | 72 +++++------ .../expressions/castToTypeParameter.fir.txt | 12 +- .../membersImportedFromObject.fir.txt | 17 ++- .../typeParameterClassLiteral.fir.txt | 8 +- 11 files changed, 193 insertions(+), 116 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/typeFromGetter.kt create mode 100644 compiler/fir/resolve/testData/resolve/typeFromGetter.txt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index 12c33b0a702..b5193323c8e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -94,21 +94,12 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn return data.compose() } - override fun transformFunction(function: FirFunction, data: Any?): CompositeTransformResult { - return withScopeCleanup(localScopes) { - localScopes += FirLocalScope() - super.transformFunction(function, data) - } - } - - override fun transformValueParameter(valueParameter: FirValueParameter, data: Any?): CompositeTransformResult { localScopes.lastOrNull()?.storeDeclaration(valueParameter) if (valueParameter.returnTypeRef is FirImplicitTypeRef) return valueParameter.compose() // TODO return super.transformValueParameter(valueParameter, valueParameter.returnTypeRef) } - private inline fun withLabelAndReceiverType(labelName: Name, owner: FirElement, type: ConeKotlinType, block: () -> T): T { labels.put(labelName, type) when (owner) { @@ -871,34 +862,69 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn return (annotationCall.transformChildren(this, data) as FirStatement).compose() } + override fun transformFunction(function: FirFunction, data: Any?): CompositeTransformResult { + return withScopeCleanup(localScopes) { + localScopes += FirLocalScope() + super.transformFunction(function, data) + } + } + + private fun transformFunctionWithGivenSignature( + function: FirFunction, + returnTypeRef: FirTypeRef, + receiverTypeRef: FirTypeRef? = null + ): CompositeTransformResult { + if (function is FirNamedFunction) { + localScopes.lastOrNull()?.storeDeclaration(function) + } + return withScopeCleanup(scopes) { + scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe()?.scope(session, scopeSession)) + + val result = transformFunction(function, returnTypeRef).single as FirFunction + val body = result.body + if (result is FirTypedDeclaration && result.returnTypeRef is FirImplicitTypeRef && body != null) { + result.transformReturnTypeRef(this, body.resultType) + result + } else { + result + }.compose() + } + } + override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Any?): CompositeTransformResult { - if (namedFunction.returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return namedFunction.compose() - if (namedFunction.returnTypeRef is FirImplicitTypeRef) { + val returnTypeRef = namedFunction.returnTypeRef + if ((returnTypeRef !is FirImplicitTypeRef || returnTypeRef is FirResolvedTypeRef) && implicitTypeOnly) { + return namedFunction.compose() + } + if (returnTypeRef is FirImplicitTypeRef && returnTypeRef !is FirResolvedTypeRef) { namedFunction.transformReturnTypeRef(StoreType, FirComputingImplicitTypeRef) } val receiverTypeRef = namedFunction.receiverTypeRef - fun transform(): CompositeTransformResult { - localScopes.lastOrNull()?.storeDeclaration(namedFunction) - return withScopeCleanup(scopes) { - scopes.addIfNotNull(receiverTypeRef?.coneTypeSafe()?.scope(session, scopeSession)) - - - val result = super.transformNamedFunction(namedFunction, namedFunction.returnTypeRef).single as FirNamedFunction - val body = result.body - if (result.returnTypeRef is FirImplicitTypeRef && body != null) { - result.transformReturnTypeRef(this, body.resultType) - result - } else { - result - }.compose() - } - } - return if (receiverTypeRef != null) { - withLabelAndReceiverType(namedFunction.name, namedFunction, receiverTypeRef.coneTypeUnsafe()) { transform() } + withLabelAndReceiverType(namedFunction.name, namedFunction, receiverTypeRef.coneTypeUnsafe()) { + transformFunctionWithGivenSignature(namedFunction, returnTypeRef, receiverTypeRef) + } } else { - transform() + transformFunctionWithGivenSignature(namedFunction, returnTypeRef) + } + } + + override fun transformPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Any?): CompositeTransformResult { + if (propertyAccessor is FirDefaultPropertyAccessor || propertyAccessor.body == null) { + return super.transformPropertyAccessor(propertyAccessor, data) + } + val returnTypeRef = propertyAccessor.returnTypeRef + if ((returnTypeRef !is FirImplicitTypeRef || returnTypeRef is FirResolvedTypeRef) && implicitTypeOnly) { + return propertyAccessor.compose() + } + if (returnTypeRef is FirImplicitTypeRef && returnTypeRef !is FirResolvedTypeRef && data !is FirResolvedTypeRef) { + propertyAccessor.transformReturnTypeRef(StoreType, FirComputingImplicitTypeRef) + } + return if (data is FirResolvedTypeRef && returnTypeRef !is FirResolvedTypeRef) { + transformFunctionWithGivenSignature(propertyAccessor, data) + } else { + transformFunctionWithGivenSignature(propertyAccessor, returnTypeRef) } } @@ -933,17 +959,22 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn ) ) } - else -> { + variable is FirProperty && variable.getter !is FirDefaultPropertyAccessor -> { variable.transformReturnTypeRef( this, - FirErrorTypeRefImpl( - session, null, - if (variable is FirProperty && variable.getter !is FirDefaultPropertyAccessor) { - "Not supported: type from property getter" - } else { - "Cannot infer variable type without initializer / getter / delegate" - } - ) + when (val resultType = variable.getter.returnTypeRef) { + is FirImplicitTypeRef -> FirErrorTypeRefImpl( + session, + null, + "No result type for getter" + ) + else -> resultType + } + ) + } + else -> { + variable.transformReturnTypeRef( + this, FirErrorTypeRefImpl(session, null, "Cannot infer variable type without initializer / getter / delegate") ) } } @@ -966,13 +997,19 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn localScopes.addIfNotNull(primaryConstructorParametersScope) withContainer(property) { property.transformChildrenWithoutAccessors(this, returnTypeRef) - storeVariableReturnType(property) + if (property.returnTypeRef is FirImplicitTypeRef && property.initializer != null) { + storeVariableReturnType(property) + } withScopeCleanup(localScopes) { localScopes.add(FirLocalScope().apply { storeBackingField(property) }) - val enhancedTypeRef = property.returnTypeRef + var enhancedTypeRef = property.returnTypeRef property.getter.transform(this, enhancedTypeRef) + if (property.returnTypeRef is FirImplicitTypeRef) { + storeVariableReturnType(property) + enhancedTypeRef = property.returnTypeRef + } property.setter?.let { it.transform(this, enhancedTypeRef) it.valueParameters[0].transformReturnTypeRef(StoreType, enhancedTypeRef) diff --git a/compiler/fir/resolve/testData/resolve/typeFromGetter.kt b/compiler/fir/resolve/testData/resolve/typeFromGetter.kt new file mode 100644 index 00000000000..035f9be3c88 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/typeFromGetter.kt @@ -0,0 +1,12 @@ +val x get() = 1 + +val y: Int get() = 1 + +val z = 1 + get() = field + +val w: Int get(): Int = 1 + +interface Some { + val bar: Int get() = 1 +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/typeFromGetter.txt b/compiler/fir/resolve/testData/resolve/typeFromGetter.txt new file mode 100644 index 00000000000..9b1223176ac --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/typeFromGetter.txt @@ -0,0 +1,24 @@ +FILE: typeFromGetter.kt + public final val x: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(1) + } + public final val y: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(1) + } + public final val z: R|kotlin/Int| = Int(1) + public get(): R|kotlin/Int| { + ^ F|/z| + } + public final val w: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(1) + } + public abstract interface Some : R|kotlin/Any| { + public open val bar: R|kotlin/Int| + public get(): R|kotlin/Int| { + ^ Int(1) + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java index 202741285c6..546990247a4 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -144,6 +144,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/typeAliasWithGeneric.kt"); } + @TestMetadata("typeFromGetter.kt") + public void testTypeFromGetter() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/typeFromGetter.kt"); + } + @TestMetadata("typeParameterInPropertyReceiver.kt") public void testTypeParameterInPropertyReceiver() throws Exception { runTest("compiler/fir/resolve/testData/resolve/typeParameterInPropertyReceiver.kt"); diff --git a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt index 64a6eac67da..ad11cb816b8 100644 --- a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt @@ -63,10 +63,10 @@ FILE fqName: fileName:/classLiteralInAnnotation.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test2.' type=.test2. origin=null PROPERTY name:test3 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Any correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' BLOCK type=.. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] annotations: @@ -77,9 +77,9 @@ FILE fqName: fileName:/classLiteralInAnnotation.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in ..' type=.. origin=null - FUN name: visibility:public modality:FINAL <> (v:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (v:kotlin.Any) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:v index:0 type:IrErrorType + VALUE_PARAMETER name:v index:0 type:kotlin.Any BLOCK_BODY BLOCK type=.. origin=OBJECT_LITERAL CLASS OBJECT name: modality:FINAL visibility:local superTypes:[kotlin.Any] diff --git a/compiler/testData/ir/irText/declarations/extensionProperties.fir.txt b/compiler/testData/ir/irText/declarations/extensionProperties.fir.txt index e5dd04cc324..e952d89e271 100644 --- a/compiler/testData/ir/irText/declarations/extensionProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/extensionProperties.fir.txt @@ -1,19 +1,19 @@ FILE fqName: fileName:/extensionProperties.kt PROPERTY name:test1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 PROPERTY name:test2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host @@ -22,23 +22,23 @@ FILE fqName: fileName:/extensionProperties.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' PROPERTY name:test3 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 PROPERTY name:test4 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> ($this:.Host, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.Host, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: diff --git a/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt b/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt index 89317318b12..2b8cefa272b 100644 --- a/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt +++ b/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt @@ -34,22 +34,22 @@ FILE fqName: fileName:/localClassWithOverrides.kt FIELD PROPERTY_BACKING_FIELD name:aval type:kotlin.Int visibility:public [final] EXPRESSION_BODY CONST Int type=kotlin.Int value=1 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.outer.Local) returnType:IrErrorType + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.outer.Local) returnType:kotlin.Int correspondingProperty: PROPERTY name:aval visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.outer.Local BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .outer.Local' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .outer.Local' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aval type:kotlin.Int visibility:public [final] ' type=kotlin.Int origin=null receiver: GET_VAR ': .outer.Local declared in .outer.Local.' type=.outer.Local origin=null PROPERTY name:avar visibility:public modality:FINAL [var] FIELD PROPERTY_BACKING_FIELD name:avar type:kotlin.Int visibility:public EXPRESSION_BODY CONST Int type=kotlin.Int value=2 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.outer.Local) returnType:IrErrorType + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.outer.Local) returnType:kotlin.Int correspondingProperty: PROPERTY name:avar visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.outer.Local BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .outer.Local' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .outer.Local' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:avar type:kotlin.Int visibility:public ' type=kotlin.Int origin=null receiver: GET_VAR ': .outer.Local declared in .outer.Local.' type=.outer.Local origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.outer.Local, :kotlin.Int) returnType:kotlin.Unit diff --git a/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.fir.txt b/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.fir.txt index 96c78d2bb68..927df63c787 100644 --- a/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/propertyAccessors.fir.txt @@ -1,51 +1,51 @@ FILE fqName: fileName:/propertyAccessors.kt PROPERTY name:test1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 PROPERTY name:test2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY PROPERTY name:testExt1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:testExt1 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 PROPERTY name:testExt2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:testExt2 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:testExt2 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY PROPERTY name:testExt3 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:testExt3 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 PROPERTY name:testExt4 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:testExt4 visibility:public modality:FINAL [var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:testExt4 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host @@ -55,61 +55,61 @@ FILE fqName: fileName:/propertyAccessors.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' PROPERTY name:testMem1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMem1 visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 PROPERTY name:testMem2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMem2 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> ($this:.Host, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.Host, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:testMem2 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY PROPERTY name:testMemExt1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMemExt1 visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 PROPERTY name:testMemExt2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMemExt2 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> ($this:.Host, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.Host, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:testMemExt2 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY PROPERTY name:testMemExt3 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMemExt3 visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 PROPERTY name:testMemExt4 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Int correspondingProperty: PROPERTY name:testMemExt4 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Host' CONST Int type=kotlin.Int value=42 - FUN name: visibility:public modality:FINAL <> ($this:.Host, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.Host, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:testMemExt4 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.Host - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: diff --git a/compiler/testData/ir/irText/expressions/castToTypeParameter.fir.txt b/compiler/testData/ir/irText/expressions/castToTypeParameter.fir.txt index ecd6f990d5e..e83e6c69295 100644 --- a/compiler/testData/ir/irText/expressions/castToTypeParameter.fir.txt +++ b/compiler/testData/ir/irText/expressions/castToTypeParameter.fir.txt @@ -13,10 +13,10 @@ FILE fqName: fileName:/castToTypeParameter.kt TYPE_OP type=T of .castExtFun origin=CAST typeOperand=T of .castExtFun ERROR_CALL 'Unresolved reference: this#' type=kotlin.Any PROPERTY name:castExtVal visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:T of correspondingProperty: PROPERTY name:castExtVal visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): T of declared in ' TYPE_OP type=T of origin=CAST typeOperand=T of ERROR_CALL 'Unresolved reference: this#' type=IrErrorType CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] @@ -55,19 +55,19 @@ FILE fqName: fileName:/castToTypeParameter.kt TYPE_OP type=TF of .Host.castGenericMemberExtFun origin=CAST typeOperand=TF of .Host.castGenericMemberExtFun ERROR_CALL 'Unresolved reference: this#' type=kotlin.Any PROPERTY name:castMemberExtVal visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:T of .Host correspondingProperty: PROPERTY name:castMemberExtVal visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): T of .Host declared in .Host' TYPE_OP type=T of .Host origin=CAST typeOperand=T of .Host ERROR_CALL 'Unresolved reference: this#' type=.Host.Host> PROPERTY name:castGenericMemberExtVal visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:TV of correspondingProperty: PROPERTY name:castGenericMemberExtVal visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): TV of declared in .Host' TYPE_OP type=TV of origin=CAST typeOperand=TV of ERROR_CALL 'Unresolved reference: this#' type=.Host.Host> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean diff --git a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt index 72f17f103e0..c1a2ed8d161 100644 --- a/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/membersImportedFromObject.fir.txt @@ -27,12 +27,12 @@ FILE fqName: fileName:/membersImportedFromObject.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:public [final] ' type=kotlin.Int origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null PROPERTY name:barExt visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.A) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int correspondingProperty: PROPERTY name:barExt visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.A BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .A' - CONST Int type=IrErrorType value=43 + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' + CONST Int type=kotlin.Int value=43 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any @@ -75,13 +75,12 @@ FILE fqName: fileName:/membersImportedFromObject.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null PROPERTY name:test4 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:public [final,static] + FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): IrErrorType declared in .A' type=IrErrorType origin=null + CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null $this: CONST Int type=kotlin.Int value=1 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null - + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/typeParameterClassLiteral.fir.txt b/compiler/testData/ir/irText/expressions/typeParameterClassLiteral.fir.txt index 2bd9f85894e..69c1d098ff2 100644 --- a/compiler/testData/ir/irText/expressions/typeParameterClassLiteral.fir.txt +++ b/compiler/testData/ir/irText/expressions/typeParameterClassLiteral.fir.txt @@ -12,10 +12,10 @@ FILE fqName: fileName:/typeParameterClassLiteral.kt GET_CLASS type=kotlin.reflect.KClass ERROR_CALL 'Unresolved reference: #' type=IrErrorType PROPERTY name:classRefExtVal visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KClass correspondingProperty: PROPERTY name:classRefExtVal visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.reflect.KClass declared in ' GET_CLASS type=kotlin.reflect.KClass ERROR_CALL 'Unresolved reference: #' type=IrErrorType CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] @@ -39,11 +39,11 @@ FILE fqName: fileName:/typeParameterClassLiteral.kt GET_CLASS type=kotlin.reflect.KClass ERROR_CALL 'Unresolved reference: #' type=IrErrorType PROPERTY name:classRefGenericMemberExtVal visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FUN name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.reflect.KClass correspondingProperty: PROPERTY name:classRefGenericMemberExtVal visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' + RETURN type=kotlin.Nothing from='public final fun (): kotlin.reflect.KClass declared in .Host' GET_CLASS type=kotlin.reflect.KClass ERROR_CALL 'Unresolved reference: #' type=IrErrorType FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean