diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt index 4929f89b029..b671df6ef1c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt @@ -5,9 +5,7 @@ package org.jetbrains.kotlin.fir.resolve.calls -import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall -import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression +import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.symbols.ConeSymbol import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage @@ -49,9 +47,8 @@ fun PostponedArgumentsAnalyzer.Context.addSubsystemFromExpression(expression: Fi } } -internal fun FirFunctionCall.candidate(): Candidate? { - val callee = this.calleeReference - return when (callee) { +internal fun FirQualifiedAccess.candidate(): Candidate? { + return when (val callee = this.calleeReference) { is FirNamedReferenceWithCandidate -> return callee.candidate else -> null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceCompletion.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceCompletion.kt index 4f8dd5ab062..28230f3513a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceCompletion.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/InferenceCompletion.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -92,7 +93,7 @@ class ConstraintSystemCompleter(val components: InferenceComponents) { fun complete( c: KotlinConstraintSystemCompleter.Context, completionMode: KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode, - topLevelAtoms: List, + topLevelAtoms: List, candidateReturnType: ConeKotlinType, analyze: (PostponedResolvedAtomMarker) -> Unit ) { @@ -159,7 +160,7 @@ class ConstraintSystemCompleter(val components: InferenceComponents) { private fun analyzePostponeArgumentIfPossible( c: KotlinConstraintSystemCompleter.Context, - topLevelAtoms: List, + topLevelAtoms: List, analyze: (PostponedResolvedAtomMarker) -> Unit ): Boolean { for (argument in getOrderedNotAnalyzedPostponedArguments(topLevelAtoms)) { @@ -171,8 +172,8 @@ class ConstraintSystemCompleter(val components: InferenceComponents) { return false } - private fun getOrderedNotAnalyzedPostponedArguments(topLevelAtoms: List): List { - fun FirExpression.process(to: MutableList) { + private fun getOrderedNotAnalyzedPostponedArguments(topLevelAtoms: List): List { + fun FirStatement.process(to: MutableList) { when (this) { is FirFunctionCall -> { val candidate = (this.calleeReference as? FirNamedReferenceWithCandidate)?.candidate 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 ff1dcc54324..19e8cecb702 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 @@ -198,7 +198,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn access.resultType = typeFromCallee(access) } - private fun typeFromCallee(access: T): FirResolvedTypeRef where T : FirQualifiedAccess, T : FirExpression { + private fun typeFromCallee(access: T): FirResolvedTypeRef where T : FirQualifiedAccess { return when (val newCallee = access.calleeReference) { is FirErrorNamedReference -> FirErrorTypeRefImpl(session, access.psi, newCallee.errorReason) @@ -232,6 +232,12 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn error("WTF ! $symbol") } } + is FirThisReference -> { + val labelName = newCallee.labelName + val types = if (labelName == null) labels.values() else labels[Name.identifier(labelName)] + val type = types.lastOrNull() ?: ConeKotlinErrorType("Unresolved this@$labelName") + FirResolvedTypeRefImpl(session, null, type, emptyList()) + } else -> error("Failed to extract type from: $newCallee") } } @@ -402,8 +408,15 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn variableAssignment: FirVariableAssignment, data: Any? ): CompositeTransformResult { - val variableAssignment = variableAssignment.transformRValue(this, null) - return transformCallee(variableAssignment).compose() + val resolvedAssignment = transformCallee(variableAssignment) + return if (resolvedAssignment is FirVariableAssignment) { + val completeAssignment = completeTypeInference(resolvedAssignment, noExpectedType) + val expectedType = typeFromCallee(completeAssignment) + completeAssignment.transformRValue(this, expectedType).compose() + } else { + // This can happen in erroneous code only + resolvedAssignment.compose() + } } override fun transformAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: Any?): CompositeTransformResult { @@ -592,13 +605,15 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn data class LambdaResolution(val expectedReturnTypeRef: FirResolvedTypeRef?) - private fun completeTypeInference(functionCall: FirFunctionCall, expectedTypeRef: FirTypeRef?): FirFunctionCall { - val typeRef = typeFromCallee(functionCall) + private fun completeTypeInference(qualifiedAccess: T, expectedTypeRef: FirTypeRef?): T { + val typeRef = typeFromCallee(qualifiedAccess) if (typeRef.type is ConeKotlinErrorType) { - functionCall.resultType = typeRef - return functionCall + if (qualifiedAccess is FirExpression) { + qualifiedAccess.resultType = typeRef + } + return qualifiedAccess } - val candidate = functionCall.candidate() ?: return functionCall + val candidate = qualifiedAccess.candidate() ?: return qualifiedAccess val initialSubstitutor = candidate.substitutor val initialType = initialSubstitutor.substituteOrSelf(typeRef.type) @@ -637,16 +652,18 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn else -> null } + + val expectedReturnTypeRef = expectedReturnType?.let { lambdaArgument.returnTypeRef.resolvedTypeFromPrototype(it) } + val newLambdaExpression = lambdaArgument.copy( receiverTypeRef = receiverType?.let { lambdaArgument.receiverTypeRef!!.resolvedTypeFromPrototype(it) }, valueParameters = lambdaArgument.valueParameters.mapIndexed { index, parameter -> parameter.transformReturnTypeRef(StoreType, parameter.returnTypeRef.resolvedTypeFromPrototype(parameters[index])) parameter } + listOfNotNull(itParam), - returnTypeRef = lambdaArgument.returnTypeRef.resolvedTypeFromPrototype(rawReturnType) + returnTypeRef = expectedReturnTypeRef ?: noExpectedType ) - val expectedReturnTypeRef = expectedReturnType?.let { newLambdaExpression.returnTypeRef.resolvedTypeFromPrototype(it) } replacements[lambdaArgument] = newLambdaExpression.transformSingle(this@FirBodyResolveTransformer, LambdaResolution(expectedReturnTypeRef)) @@ -656,7 +673,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn }, { it.resultType }, inferenceComponents) - completer.complete(candidate.system.asConstraintSystemCompleterContext(), completionMode, listOf(functionCall), initialType) { + completer.complete(candidate.system.asConstraintSystemCompleterContext(), completionMode, listOf(qualifiedAccess), initialType) { analyzer.analyze( candidate.system.asPostponedArgumentsAnalyzerContext(), it @@ -664,18 +681,18 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn ) } - functionCall.transformChildren(ReplaceInArguments, replacements.toMap()) + qualifiedAccess.transformChildren(ReplaceInArguments, replacements.toMap()) if (completionMode == KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL) { val finalSubstitutor = candidate.system.asReadOnlyStorage().buildAbstractResultingSubstitutor(inferenceComponents.ctx) as ConeSubstitutor - return functionCall.transformSingle( + return qualifiedAccess.transformSingle( FirCallCompleterTransformer(session, finalSubstitutor, jump), null ) } - return functionCall + return qualifiedAccess } override fun transformTryExpression(tryExpression: FirTryExpression, data: Any?): CompositeTransformResult { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompleterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompleterTransformer.kt index c5fe7de7208..54edfeab590 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompleterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompleterTransformer.kt @@ -5,13 +5,13 @@ package org.jetbrains.kotlin.fir.resolve.transformers -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.copy +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.constructFunctionalTypeRef @@ -23,15 +23,45 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirTypeProjectionWithVarianceImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.types.Variance +object StoreCalleeReference : FirTransformer() { + override fun transformElement(element: E, data: FirResolvedCallableReference): CompositeTransformResult { + return element.compose() + } + + override fun transformResolvedCallableReference( + resolvedCallableReference: FirResolvedCallableReference, + data: FirResolvedCallableReference + ): CompositeTransformResult { + return data.compose() + } +} + class FirCallCompleterTransformer( val session: FirSession, private val finalSubstitutor: ConeSubstitutor, private val typeCalculator: ReturnTypeCalculator ) : FirAbstractTreeTransformer() { + override fun transformVariableAssignment( + variableAssignment: FirVariableAssignment, + data: Nothing? + ): CompositeTransformResult { + val calleeReference = variableAssignment.calleeReference as? FirNamedReferenceWithCandidate + ?: return variableAssignment.compose() + return variableAssignment.transformCalleeReference( + StoreCalleeReference, + FirResolvedCallableReferenceImpl( + calleeReference.session, + calleeReference.psi, + calleeReference.name, + calleeReference.coneSymbol + ) + ).compose() + } override fun transformFunctionCall(functionCall: FirFunctionCall, data: Nothing?): CompositeTransformResult { val calleeReference = functionCall.calleeReference as? FirNamedReferenceWithCandidate ?: return functionCall.compose() diff --git a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt index 1d231c2ab24..7e3289dd9ed 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.kt @@ -7,7 +7,14 @@ var b: MutableSet? = null field = HashSet() } +var MutableSet.d: T? get() = null + set(_) {} + +fun produce(): T = TODO() + fun foo() { var c: MutableSet? = null c = HashSet() + + c!!.d = produce() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt index f6a513b7b8e..699ed51e0c5 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt @@ -4,9 +4,27 @@ FILE: hashSet.kt public final var b: R|kotlin/collections/MutableSet|? = Null(null) public get(): R|kotlin/collections/MutableSet|? public set(_: R|kotlin/collections/MutableSet|?): R|kotlin/Unit| { - F|/b| = R|java/util/HashSet.HashSet|() + F|/b| = R|java/util/HashSet.HashSet|() } + public final var R|kotlin/collections/MutableSet|.d: R|T|? + public get(): R|T|? { + ^ Null(null) + } + public set(_: R|T|?): R|kotlin/Unit| { + } + public final fun produce(): R|T| { + ^produce R|kotlin/TODO|() + } public final fun foo(): R|kotlin/Unit| { lvar c: R|kotlin/collections/MutableSet|? = Null(null) - R|/c| = R|java/util/HashSet.HashSet|() + R|/c| = R|java/util/HashSet.HashSet|() + when (lval : R|kotlin/collections/MutableSet|? = R|/c|) { + ==($subj$, Null(null)) -> { + throw R|kotlin/KotlinNullPointerException.KotlinNullPointerException|() + } + else -> { + R|/|! + } + } + .R|/d| = R|/produce|() } diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt index 14ab28f1b0c..7813f945695 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt @@ -8,11 +8,11 @@ FILE fqName: fileName:/localDelegatedProperties.kt BLOCK_BODY VAR name:x type:IrErrorType [var] SET_VAR 'var x: IrErrorType [var] declared in .test2' type=IrErrorType origin=null - CONST Int type=kotlin.Int value=0 + CONST Int type=IrErrorType value=0 VAR name: type:IrErrorType [val] GET_VAR 'var x: IrErrorType [var] declared in .test2' type=IrErrorType origin=null SET_VAR 'var x: IrErrorType [var] declared in .test2' type=IrErrorType origin=null ERROR_CALL 'Unresolved reference: #' type=IrErrorType GET_VAR 'val : IrErrorType [val] declared in .test2' type=IrErrorType origin=null SET_VAR 'var x: IrErrorType [var] declared in .test2' type=IrErrorType origin=null - CONST Int type=kotlin.Int value=1 + CONST Int type=IrErrorType value=1 diff --git a/compiler/testData/ir/irText/expressions/augmentedAssignment2.fir.txt b/compiler/testData/ir/irText/expressions/augmentedAssignment2.fir.txt index d6103d42ecd..86ba327fa78 100644 --- a/compiler/testData/ir/irText/expressions/augmentedAssignment2.fir.txt +++ b/compiler/testData/ir/irText/expressions/augmentedAssignment2.fir.txt @@ -47,25 +47,24 @@ FILE fqName: fileName:/augmentedAssignment2.kt VAR name:a type:.A [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null SET_VAR 'val a: .A [val] declared in .testVariable' type=.A origin=null - CONST String type=kotlin.String value="+=" + CONST String type=.A value="+=" SET_VAR 'val a: .A [val] declared in .testVariable' type=.A origin=null - CONST String type=kotlin.String value="-=" + CONST String type=.A value="-=" SET_VAR 'val a: .A [val] declared in .testVariable' type=.A origin=null - CONST String type=kotlin.String value="*=" + CONST String type=.A value="*=" SET_VAR 'val a: .A [val] declared in .testVariable' type=.A origin=null - CONST String type=kotlin.String value="/=" + CONST String type=.A value="/=" SET_VAR 'val a: .A [val] declared in .testVariable' type=.A origin=null - CONST String type=kotlin.String value="*=" + CONST String type=.A value="*=" FUN name:testProperty visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:.A visibility:public [final,static] ' type=.A origin=null - value: CONST String type=kotlin.String value="+=" + value: CONST String type=.A value="+=" SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:.A visibility:public [final,static] ' type=.A origin=null - value: CONST String type=kotlin.String value="-=" + value: CONST String type=.A value="-=" SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:.A visibility:public [final,static] ' type=.A origin=null - value: CONST String type=kotlin.String value="*=" + value: CONST String type=.A value="*=" SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:.A visibility:public [final,static] ' type=.A origin=null - value: CONST String type=kotlin.String value="/=" + value: CONST String type=.A value="/=" SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:.A visibility:public [final,static] ' type=.A origin=null - value: CONST String type=kotlin.String value="%=" - + value: CONST String type=.A value="%=" diff --git a/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt b/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt index 0dfb1edf7be..51a13c821a1 100644 --- a/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt +++ b/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt @@ -38,11 +38,11 @@ FILE fqName: fileName:/augmentedAssignmentWithExpression.kt VAR name: type:.Host [val] CALL 'public final fun foo (): .Host declared in ' type=.Host origin=null SET_VAR 'val : .Host [val] declared in .test3' type=.Host origin=null - CONST Int type=kotlin.Int value=1 + CONST Int type=.Host value=1 FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Function0<.Host>) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0<.Host> BLOCK_BODY VAR name: type:IrErrorType [val] ERROR_CALL 'Unresolved reference: #' type=IrErrorType SET_VAR 'val : IrErrorType [val] declared in .test4' type=IrErrorType origin=null - CONST Int type=kotlin.Int value=1 + CONST Int type=IrErrorType value=1 diff --git a/compiler/testData/ir/irText/expressions/kt16904.fir.txt b/compiler/testData/ir/irText/expressions/kt16904.fir.txt index 0f72412e9e1..69c3b78d693 100644 --- a/compiler/testData/ir/irText/expressions/kt16904.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt16904.fir.txt @@ -76,7 +76,7 @@ FILE fqName: fileName:/kt16904.kt CONSTRUCTOR visibility:public <> () returnType:.Test1 BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.B visibility:public [final] ' type=.B origin=null - value: CONST Int type=kotlin.Int value=42 + value: CONST Int type=.B value=42 SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=42 DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' diff --git a/compiler/testData/ir/irText/expressions/kt30020.fir.txt b/compiler/testData/ir/irText/expressions/kt30020.fir.txt index 15074e2822a..6a3067aab21 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.fir.txt @@ -29,19 +29,19 @@ FILE fqName: fileName:/kt30020.kt CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null SET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null - CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.collections.MutableList value=2 VAR name: type:kotlin.collections.MutableList [val] TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null SET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null - CONST Int type=kotlin.Int value=3 + CONST Int type=kotlin.collections.MutableList value=3 VAR name: type:kotlin.collections.MutableList [val] TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null SET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null - CONST Int type=kotlin.Int value=4 + CONST Int type=kotlin.collections.MutableList value=4 VAR name: type:kotlin.collections.MutableList [val] BLOCK type=kotlin.collections.MutableList origin=EXCLEXCL VAR name: type:kotlin.collections.MutableList? [val] @@ -58,7 +58,7 @@ FILE fqName: fileName:/kt30020.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val : kotlin.collections.MutableList? [val] declared in .test' type=kotlin.collections.MutableList? origin=null SET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null - CONST Int type=kotlin.Int value=5 + CONST Int type=kotlin.collections.MutableList value=5 VAR name: type:kotlin.collections.MutableList [val] BLOCK type=kotlin.collections.MutableList origin=EXCLEXCL VAR name: type:kotlin.collections.MutableList [val] @@ -75,7 +75,7 @@ FILE fqName: fileName:/kt30020.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null SET_VAR 'val : kotlin.collections.MutableList [val] declared in .test' type=kotlin.collections.MutableList origin=null - CONST Int type=kotlin.Int value=6 + CONST Int type=kotlin.collections.MutableList value=6 FUN name:testExtensionReceiver visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY ERROR_CALL 'Unresolved reference: this#' type=IrErrorType diff --git a/compiler/testData/ir/irText/expressions/safeAssignment.fir.txt b/compiler/testData/ir/irText/expressions/safeAssignment.fir.txt index 9f65eca5383..5f032f23b26 100644 --- a/compiler/testData/ir/irText/expressions/safeAssignment.fir.txt +++ b/compiler/testData/ir/irText/expressions/safeAssignment.fir.txt @@ -42,5 +42,4 @@ FILE fqName: fileName:/safeAssignment.kt VALUE_PARAMETER name:nc index:0 type:.C? BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public ' type=kotlin.Int origin=null - value: CONST Int type=kotlin.Int value=42 - + value: CONST Int type=kotlin.Int? value=42 diff --git a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt index 07cb86bfe05..98314bbb337 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt @@ -81,7 +81,7 @@ FILE fqName: fileName:/safeCalls.kt VALUE_PARAMETER name:x index:0 type:.Ref? BLOCK_BODY SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:public ' type=kotlin.Int origin=null - value: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int? value=0 FUN name:test5 visibility:public modality:FINAL <> (s:kotlin.String?) returnType:kotlin.Int VALUE_PARAMETER name:s index:0 type:kotlin.String? BLOCK_BODY diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt index 12437f100dd..b75400185b9 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt @@ -83,25 +83,25 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt VALUE_PARAMETER name:fooImpl index:0 type:.IFoo VALUE_PARAMETER name:invokeImpl index:1 type:.IInvoke BLOCK_BODY - CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Unit origin=null receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - block: BLOCK type=kotlin.Function2<.A, .A, kotlin.Nothing> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.A) returnType:kotlin.Nothing + block: BLOCK type=kotlin.Function2<.A, .A, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.A) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:.A BLOCK_BODY - CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Unit origin=null receiver: GET_VAR 'fooImpl: .IFoo declared in .test' type=.IFoo origin=null - block: BLOCK type=kotlin.Function2<.IFoo, .IFoo, kotlin.Nothing> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IFoo) returnType:kotlin.Nothing + block: BLOCK type=kotlin.Function2<.IFoo, .IFoo, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IFoo) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:.IFoo BLOCK_BODY - CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Unit origin=null receiver: GET_VAR 'invokeImpl: .IInvoke declared in .test' type=.IInvoke origin=null - block: BLOCK type=kotlin.Function2<.IInvoke, .IInvoke, kotlin.Nothing> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IInvoke) returnType:kotlin.Nothing + block: BLOCK type=kotlin.Function2<.IInvoke, .IInvoke, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.IInvoke) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:.IInvoke BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'local final fun (it: .IInvoke): kotlin.Nothing declared in .test..' type=kotlin.Function2<.IInvoke, .IInvoke, kotlin.Nothing> origin=LAMBDA - FUNCTION_REFERENCE 'local final fun (it: .IFoo): kotlin.Nothing declared in .test.' type=kotlin.Function2<.IFoo, .IFoo, kotlin.Nothing> origin=LAMBDA - FUNCTION_REFERENCE 'local final fun (it: .A): kotlin.Nothing declared in .test' type=kotlin.Function2<.A, .A, kotlin.Nothing> origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (it: .IInvoke): kotlin.Unit declared in .test..' type=kotlin.Function2<.IInvoke, .IInvoke, kotlin.Unit> origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (it: .IFoo): kotlin.Unit declared in .test.' type=kotlin.Function2<.IFoo, .IFoo, kotlin.Unit> origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (it: .A): kotlin.Unit declared in .test' type=kotlin.Function2<.A, .A, kotlin.Unit> origin=LAMBDA diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt index 7b7c44fe85b..d614bc793e1 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt @@ -1,45 +1,45 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:test0 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - block: BLOCK type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Unit origin=null + block: BLOCK type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test0' + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test0' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUNCTION_REFERENCE 'local final fun (): kotlin.Nothing declared in .test0' type=kotlin.Function0 origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (): kotlin.Unit declared in .test0' type=kotlin.Function0 origin=LAMBDA FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - block: BLOCK type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Unit origin=null + block: BLOCK type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test1' + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test1' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUNCTION_REFERENCE 'local final fun (): kotlin.Nothing declared in .test1' type=kotlin.Function0 origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (): kotlin.Unit declared in .test1' type=kotlin.Function0 origin=LAMBDA FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - block: BLOCK type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Unit origin=null + block: BLOCK type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test2' + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test2' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUNCTION_REFERENCE 'local final fun (): kotlin.Nothing declared in .test2' type=kotlin.Function0 origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (): kotlin.Unit declared in .test2' type=kotlin.Function0 origin=LAMBDA FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - block: BLOCK type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Unit origin=null + block: BLOCK type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - block: BLOCK type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing + CALL 'public final fun run (block: kotlin.Function0>): R of [inline] declared in kotlin' type=kotlin.Unit origin=null + block: BLOCK type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Nothing declared in .test3.' + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test3.' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUNCTION_REFERENCE 'local final fun (): kotlin.Nothing declared in .test3.' type=kotlin.Function0 origin=LAMBDA - FUNCTION_REFERENCE 'local final fun (): kotlin.Nothing declared in .test3' type=kotlin.Function0 origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (): kotlin.Unit declared in .test3.' type=kotlin.Function0 origin=LAMBDA + FUNCTION_REFERENCE 'local final fun (): kotlin.Unit declared in .test3' type=kotlin.Function0 origin=LAMBDA FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY