diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt index d4885bf5d6e..3ad6bc6825f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt @@ -12,6 +12,8 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl +import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.constructClassType @@ -96,7 +98,8 @@ class Candidate( val implicitExtensionReceiverValue: ImplicitReceiverValue?, val explicitReceiverKind: ExplicitReceiverKind, private val inferenceComponents: InferenceComponents, - private val baseSystem: ConstraintStorage + private val baseSystem: ConstraintStorage, + val callInfo: CallInfo ) { val system by lazy { val system = inferenceComponents.createConstraintSystem() @@ -281,7 +284,8 @@ class ScopeTowerLevel( if (candidate.hasConsistentExtensionReceiver(extensionReceiver) && candidate.dispatchReceiverValue() == null) { processor.consumeCandidate( candidate as T, dispatchReceiverValue = null, - implicitExtensionReceiverValue = implicitExtensionReceiver) + implicitExtensionReceiverValue = implicitExtensionReceiver + ) } else { ProcessorAction.NEXT } @@ -342,15 +346,15 @@ class QualifiedReceiverTowerDataConsumer( val name: Name, val token: TowerScopeLevel.Token, val explicitReceiver: ExpressionReceiverValue, - val candidateFactory: CandidateFactory + val candidateFactory: CandidateFactory, + val resultCollector: CandidateCollector ) : TowerDataConsumer() { override fun consume( kind: TowerDataKind, towerScopeLevel: TowerScopeLevel, - resultCollector: CandidateCollector, group: Int ): ProcessorAction { - if (checkSkip(group, resultCollector)) return ProcessorAction.NEXT + if (skipGroup(group, resultCollector)) return ProcessorAction.NEXT if (kind != TowerDataKind.EMPTY) return ProcessorAction.NEXT return QualifiedReceiverTowerLevel(session).processElementsByName( @@ -385,16 +389,16 @@ abstract class TowerDataConsumer { abstract fun consume( kind: TowerDataKind, towerScopeLevel: TowerScopeLevel, - resultCollector: CandidateCollector, +// resultCollector: CandidateCollector, group: Int ): ProcessorAction private var stopGroup = Int.MAX_VALUE - fun checkSkip(group: Int, resultCollector: CandidateCollector): Boolean { + fun skipGroup(group: Int, resultCollector: CandidateCollector): Boolean { if (resultCollector.isSuccess() && stopGroup == Int.MAX_VALUE) { stopGroup = group - } - return group > stopGroup + } else if (group > stopGroup) return true + return false } } @@ -403,39 +407,94 @@ fun createVariableAndObjectConsumer( session: FirSession, name: Name, callInfo: CallInfo, - inferenceComponents: InferenceComponents + inferenceComponents: InferenceComponents, + resultCollector: CandidateCollector ): TowerDataConsumer { return PrioritizedTowerDataConsumer( + resultCollector, createSimpleConsumer( session, name, TowerScopeLevel.Token.Properties, callInfo, - inferenceComponents + inferenceComponents, + resultCollector ), createSimpleConsumer( session, name, TowerScopeLevel.Token.Objects, callInfo, - inferenceComponents + inferenceComponents, + resultCollector ) ) } -fun createFunctionConsumer( +fun createSimpleFunctionConsumer( session: FirSession, name: Name, callInfo: CallInfo, - inferenceComponents: InferenceComponents + inferenceComponents: InferenceComponents, + resultCollector: CandidateCollector ): TowerDataConsumer { return createSimpleConsumer( session, name, TowerScopeLevel.Token.Functions, callInfo, - inferenceComponents + inferenceComponents, + resultCollector + ) +} + +fun createFunctionConsumer( + session: FirSession, + name: Name, + callInfo: CallInfo, + inferenceComponents: InferenceComponents, + resultCollector: CandidateCollector, + callResolver: CallResolver +): TowerDataConsumer { + val varCallInfo = CallInfo( + CallKind.VariableAccess, + callInfo.explicitReceiver, + emptyList(), + callInfo.isSafeCall, + callInfo.typeArguments, + inferenceComponents.session, + callInfo.containingFile, + callInfo.container, + callInfo.typeProvider + ) + return PrioritizedTowerDataConsumer( + resultCollector, + createSimpleConsumer( + session, + name, + TowerScopeLevel.Token.Functions, + callInfo, + inferenceComponents, + resultCollector + ), + MultiplexerTowerDataConsumer(resultCollector).apply { + addConsumer( + createSimpleConsumer( + session, + name, + TowerScopeLevel.Token.Properties, + varCallInfo, + inferenceComponents, + InvokeCandidateCollector( + callResolver, + invokeCallInfo = callInfo, + components = inferenceComponents, + multiplexer = this + ) + ) + ) + } ) } @@ -445,7 +504,8 @@ fun createSimpleConsumer( name: Name, token: TowerScopeLevel.Token<*>, callInfo: CallInfo, - inferenceComponents: InferenceComponents + inferenceComponents: InferenceComponents, + resultCollector: CandidateCollector ): TowerDataConsumer { val factory = CandidateFactory(inferenceComponents, callInfo) val explicitReceiver = callInfo.explicitReceiver @@ -453,39 +513,40 @@ fun createSimpleConsumer( val receiverValue = ExpressionReceiverValue(explicitReceiver, callInfo.typeProvider) if (explicitReceiver is FirResolvedQualifier) { val qualified = - QualifiedReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + QualifiedReceiverTowerDataConsumer(session, name, token, receiverValue, factory, resultCollector) if (explicitReceiver.classId != null) { PrioritizedTowerDataConsumer( + resultCollector, qualified, - ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory, resultCollector) ) } else { qualified } } else { - ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory, resultCollector) } } else { - NoExplicitReceiverTowerDataConsumer(session, name, token, factory) + NoExplicitReceiverTowerDataConsumer(session, name, token, factory, resultCollector) } } class PrioritizedTowerDataConsumer( + val resultCollector: CandidateCollector, vararg val consumers: TowerDataConsumer ) : TowerDataConsumer() { override fun consume( kind: TowerDataKind, towerScopeLevel: TowerScopeLevel, - resultCollector: CandidateCollector, group: Int ): ProcessorAction { - if (checkSkip(group, resultCollector)) return ProcessorAction.NEXT + if (skipGroup(group, resultCollector)) return ProcessorAction.NEXT for ((index, consumer) in consumers.withIndex()) { - val action = consumer.consume(kind, towerScopeLevel, resultCollector, group * consumers.size + index) + val action = consumer.consume(kind, towerScopeLevel, group * consumers.size + index) if (action.stop()) { return ProcessorAction.STOP } @@ -494,12 +555,57 @@ class PrioritizedTowerDataConsumer( } } +class MultiplexerTowerDataConsumer( + val resultCollector: CandidateCollector +) : TowerDataConsumer() { + + val consumers = mutableListOf() + val newConsumers = mutableListOf() + + data class TowerData(val kind: TowerDataKind, val level: TowerScopeLevel, val group: Int) + + val datas = mutableListOf() + + override fun consume( + kind: TowerDataKind, + towerScopeLevel: TowerScopeLevel, + group: Int + ): ProcessorAction { + if (skipGroup(group, resultCollector)) return ProcessorAction.NEXT + consumers += newConsumers + newConsumers.clear() + datas += TowerData(kind, towerScopeLevel, group) + + for (consumer in consumers) { + val action = consumer.consume(kind, towerScopeLevel, group) + if (action.stop()) { + return ProcessorAction.STOP + } + } + return ProcessorAction.NEXT + } + + fun addConsumer(consumer: TowerDataConsumer): ProcessorAction = + run { + for ((kind, level, group) in datas) { + if (consumer.consume(kind, level, group).stop()) { + return@run ProcessorAction.STOP + } + } + return@run ProcessorAction.NEXT + }.also { + newConsumers += consumer + } +} + + class ExplicitReceiverTowerDataConsumer( val session: FirSession, val name: Name, val token: TowerScopeLevel.Token, val explicitReceiver: ExpressionReceiverValue, - val candidateFactory: CandidateFactory + val candidateFactory: CandidateFactory, + val resultCollector: CandidateCollector ) : TowerDataConsumer() { companion object { @@ -510,10 +616,9 @@ class ExplicitReceiverTowerDataConsumer( override fun consume( kind: TowerDataKind, towerScopeLevel: TowerScopeLevel, - resultCollector: CandidateCollector, group: Int ): ProcessorAction { - if (checkSkip(group, resultCollector)) return ProcessorAction.NEXT + if (skipGroup(group, resultCollector)) return ProcessorAction.NEXT return when (kind) { TowerDataKind.EMPTY -> MemberScopeTowerLevel(session, explicitReceiver, scopeSession = candidateFactory.inferenceComponents.scopeSession) @@ -598,17 +703,17 @@ class NoExplicitReceiverTowerDataConsumer( val session: FirSession, val name: Name, val token: TowerScopeLevel.Token, - val candidateFactory: CandidateFactory + val candidateFactory: CandidateFactory, + val resultCollector: CandidateCollector ) : TowerDataConsumer() { override fun consume( kind: TowerDataKind, towerScopeLevel: TowerScopeLevel, - resultCollector: CandidateCollector, group: Int ): ProcessorAction { - if (checkSkip(group, resultCollector)) return ProcessorAction.NEXT + if (skipGroup(group, resultCollector)) return ProcessorAction.NEXT return when (kind) { TowerDataKind.TOWER_LEVEL -> { @@ -639,7 +744,6 @@ class NoExplicitReceiverTowerDataConsumer( else -> ProcessorAction.NEXT } } - } class CallResolver(val typeCalculator: ReturnTypeCalculator, val components: InferenceComponents) { @@ -660,36 +764,41 @@ class CallResolver(val typeCalculator: ReturnTypeCalculator, val components: Inf towerDataConsumer.consume( TowerDataKind.TOWER_LEVEL, MemberScopeTowerLevel(session, implicitReceiverValue, scopeSession = components.scopeSession), - collector, group++ + group++ ) // This is an equivalent to the old "BothTowerLevelAndImplicitReceiver" towerDataConsumer.consume( TowerDataKind.TOWER_LEVEL, MemberScopeTowerLevel(session, implicitReceiverValue, implicitReceiverValue, components.scopeSession), - collector, group++ + group++ ) for (scope in scopes!!) { towerDataConsumer.consume( TowerDataKind.TOWER_LEVEL, ScopeTowerLevel(session, scope, implicitReceiverValue), - collector, group++ + group++ ) } return group } - fun runTowerResolver(towerDataConsumer: TowerDataConsumer, implicitReceiverValues: List): CandidateCollector { - val collector = CandidateCollector(callInfo!!, components) + val collector by lazy { CandidateCollector(components) } + lateinit var towerDataConsumer: TowerDataConsumer + private lateinit var implicitReceiverValues: List + + fun runTowerResolver(consumer: TowerDataConsumer, implicitReceiverValues: List): CandidateCollector { + this.implicitReceiverValues = implicitReceiverValues + towerDataConsumer = consumer var group = 0 - towerDataConsumer.consume(TowerDataKind.EMPTY, TowerScopeLevel.Empty, collector, group++) + towerDataConsumer.consume(TowerDataKind.EMPTY, TowerScopeLevel.Empty, group++) for (scope in scopes!!) { - towerDataConsumer.consume(TowerDataKind.TOWER_LEVEL, ScopeTowerLevel(session, scope), collector, group++) + towerDataConsumer.consume(TowerDataKind.TOWER_LEVEL, ScopeTowerLevel(session, scope), group++) } var blockDispatchReceivers = false @@ -702,13 +811,14 @@ class CallResolver(val typeCalculator: ReturnTypeCalculator, val components: Inf blockDispatchReceivers = true } } - processImplicitReceiver(towerDataConsumer, implicitReceiverValue, collector, group) + group = processImplicitReceiver(towerDataConsumer, implicitReceiverValue, collector, group) } + + return collector } - } @@ -721,7 +831,7 @@ enum class CandidateApplicability { RESOLVED } -class CandidateCollector(val callInfo: CallInfo, val components: InferenceComponents) { +open class CandidateCollector(val components: InferenceComponents) { val groupNumbers = mutableListOf() val candidates = mutableListOf() @@ -744,8 +854,8 @@ class CandidateCollector(val callInfo: CallInfo, val components: InferenceCompon val sink = CheckerSinkImpl(components) var finished = false sink.continuation = suspend { - for (stage in callInfo.callKind.sequence()) { - stage.check(candidate, sink, callInfo) + for (stage in candidate.callInfo.callKind.sequence()) { + stage.check(candidate, sink, candidate.callInfo) } }.createCoroutineUnintercepted(completion = object : Continuation { override val context: CoroutineContext @@ -769,7 +879,7 @@ class CandidateCollector(val callInfo: CallInfo, val components: InferenceCompon return sink.current } - fun consumeCandidate(group: Int, candidate: Candidate) { + open fun consumeCandidate(group: Int, candidate: Candidate): CandidateApplicability { val applicability = getApplicability(group, candidate) if (applicability > currentApplicability) { @@ -783,6 +893,8 @@ class CandidateCollector(val callInfo: CallInfo, val components: InferenceCompon candidates.add(candidate) groupNumbers.add(group) } + + return applicability } @@ -808,6 +920,47 @@ class CandidateCollector(val callInfo: CallInfo, val components: InferenceCompon } } +class InvokeCandidateCollector( + val callResolver: CallResolver, + val invokeCallInfo: CallInfo, + components: InferenceComponents, + val multiplexer: MultiplexerTowerDataConsumer +) : CandidateCollector(components) { + override fun consumeCandidate(group: Int, candidate: Candidate): CandidateApplicability { + val applicability = super.consumeCandidate(group, candidate) + + if (applicability >= CandidateApplicability.SYNTHETIC_RESOLVED) { + + val session = components.session + val boundInvokeCallInfo = CallInfo( + invokeCallInfo.callKind, + FirQualifiedAccessExpressionImpl(session, null, false).apply { + calleeReference = FirNamedReferenceWithCandidate( + session, + null, + (candidate.symbol as ConeCallableSymbol).callableId.callableName, + candidate + ) + typeRef = callResolver.typeCalculator.tryCalculateReturnType(candidate.symbol.firUnsafe()) + }, + invokeCallInfo.arguments, + invokeCallInfo.isSafeCall, + invokeCallInfo.typeArguments, + session, + invokeCallInfo.containingFile, + invokeCallInfo.container, + invokeCallInfo.typeProvider + ) + val invokeConsumer = + createSimpleFunctionConsumer(session, Name.identifier("invoke"), boundInvokeCallInfo, components, callResolver.collector) + + multiplexer.addConsumer(invokeConsumer) + } + + return applicability + } +} + fun FirCallableDeclaration.dispatchReceiverValue(session: FirSession): ClassDispatchReceiverValue? { // TODO: this is not true at least for inner class constructors if (this is FirConstructor) return null 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 b671df6ef1c..fcca40ea917 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 @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind class CandidateFactory( val inferenceComponents: InferenceComponents, - callInfo: CallInfo + val callInfo: CallInfo ) { val baseSystem: ConstraintStorage @@ -35,7 +35,7 @@ class CandidateFactory( ): Candidate { return Candidate( symbol, dispatchReceiverValue, implicitExtensionReceiverValue, - explicitReceiverKind, inferenceComponents, baseSystem + explicitReceiverKind, inferenceComponents, baseSystem, callInfo ) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirLibrarySymbolProviderImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirLibrarySymbolProviderImpl.kt index 1d0c20246ea..db5ef27c482 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirLibrarySymbolProviderImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirLibrarySymbolProviderImpl.kt @@ -15,8 +15,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl -import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl +import org.jetbrains.kotlin.fir.declarations.impl.* import org.jetbrains.kotlin.fir.deserialization.FirBuiltinAnnotationDeserializer import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol @@ -24,11 +23,12 @@ import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope -import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.ConeClassSymbol -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl +import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl @@ -38,6 +38,8 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.ProtoBasedClassDataFinder import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol import org.jetbrains.kotlin.serialization.deserialization.getName +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import java.io.InputStream @@ -168,15 +170,82 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider( this, relativeClassName.shortName(), Visibilities.PUBLIC, - Modality.OPEN, + Modality.ABSTRACT, isExpect = false, isActual = false, - classKind = ClassKind.CLASS, + classKind = ClassKind.INTERFACE, isInner = false, isCompanion = false, isData = false, isInline = false - ) + ).apply klass@{ + typeParameters.addAll((1..arity).map { + FirTypeParameterImpl( + session, + null, + FirTypeParameterSymbol(), + Name.identifier("P$it"), + Variance.IN_VARIANCE, + false + ) + }) + typeParameters.add( + FirTypeParameterImpl( + session, + null, + FirTypeParameterSymbol(), + Name.identifier("R"), + Variance.OUT_VARIANCE, + false + ) + ) + val name = Name.identifier("invoke") + addDeclaration( + FirMemberFunctionImpl( + session, + null, + FirFunctionSymbol(CallableId(packageFqName, relativeClassName, name)), + name, + Visibilities.PUBLIC, + Modality.ABSTRACT, + isExpect = false, + isActual = false, + isOverride = false, + isOperator = true, + isInfix = false, + isInline = false, + isTailRec = false, + isExternal = false, + isSuspend = false, + receiverTypeRef = null, + returnTypeRef = FirResolvedTypeRefImpl( + session, + null, + ConeTypeParameterTypeImpl( + typeParameters.last().symbol.toLookupTag(), + false + ) + ) + ).apply { + valueParameters += this@klass.typeParameters.dropLast(1).map { typeParameter -> + FirValueParameterImpl( + session, + null, + Name.identifier(typeParameter.name.asString().toLowerCase()), + FirResolvedTypeRefImpl( + session, + null, + ConeTypeParameterTypeImpl(typeParameter.symbol.toLookupTag(), false) + ), + defaultValue = null, + isCrossinline = false, + isNoinline = false, + isVararg = false + ) + } + } + ) + } } } } 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 4dc3681fde0..1febdf8c129 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 @@ -335,7 +335,8 @@ open class FirBodyResolveTransformer( val consumer = createVariableAndObjectConsumer( session, callee.name, - info, inferenceComponents + info, inferenceComponents, + resolver.collector ) val result = resolver.runTowerResolver(consumer, implicitReceiverStack.asReversed()) @@ -550,7 +551,7 @@ open class FirBodyResolveTransformer( resolver.callInfo = info resolver.scopes = (scopes + localScopes).asReversed() - val consumer = createFunctionConsumer(session, name, info, inferenceComponents) + val consumer = createFunctionConsumer(session, name, info, inferenceComponents, resolver.collector, resolver) val result = resolver.runTowerResolver(consumer, implicitReceiverStack.asReversed()) val bestCandidates = result.bestCandidates() val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) { @@ -596,11 +597,23 @@ open class FirBodyResolveTransformer( ) val resultExpression = functionCall.transformCalleeReference(StoreNameReference, nameReference) as FirFunctionCall - val typeRef = typeFromCallee(functionCall) - if (typeRef.type is ConeKotlinErrorType) { - functionCall.resultType = typeRef + val candidate = resultExpression.candidate() + + // We need desugaring + val resultFunctionCall = if (candidate != null && candidate.callInfo != info) { + functionCall.copy( + explicitReceiver = candidate.callInfo.explicitReceiver, + arguments = candidate.callInfo.arguments, + safe = candidate.callInfo.isSafeCall + ) + } else { + resultExpression } - return resultExpression + val typeRef = typeFromCallee(resultFunctionCall) + if (typeRef.type is ConeKotlinErrorType) { + resultFunctionCall.resultType = typeRef + } + return resultFunctionCall } data class LambdaResolution(val expectedReturnTypeRef: FirResolvedTypeRef?) @@ -1270,6 +1283,18 @@ internal object StoreType : FirTransformer() { } } +internal object StoreExplicitReceiver : FirTransformer() { + override fun transformElement(element: E, data: FirExpression): CompositeTransformResult { + return element.compose() + } + + override fun transformExpression(expression: FirExpression, data: FirExpression): CompositeTransformResult { + return data.compose() + } + + +} + private object ReplaceInArguments : FirTransformer>() { override fun transformElement(element: E, data: Map): CompositeTransformResult { return ((data[element] ?: element) as E).compose() diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.txt index 945af2320ec..cbdfde9aac4 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.txt @@ -13,8 +13,8 @@ FILE: explicitReceiver.kt ^invoke this# } - public final fun bar(): R|kotlin/Unit| { - ^bar R|/x|() + public final fun bar(): R|Foo| { + ^bar R|/Foo.x|.R|/Foo.invoke|() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver2.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver2.txt index 796a5130da3..34e929ab808 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver2.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver2.txt @@ -23,8 +23,8 @@ FILE: explicitReceiver2.kt public final val x: R|Bar| = R|/Bar.Bar|() public get(): R|Bar| - public final fun bar(): R|kotlin/Unit| { - ^bar R|/x|() + public final fun bar(): R|Foo| { + ^bar R|/Foo.x|.R|/Bar.invoke|() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/extension.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/extension.kt index 2c22274f0aa..ebe97fbd7af 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/extension.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/extension.kt @@ -7,5 +7,5 @@ class Foo { val x = 0 - fun foo() = x() + fun foo() = x() // should resolve to invoke } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/farInvokeExtension.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/farInvokeExtension.kt index eaf10f06d4c..3b464150f41 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/farInvokeExtension.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/farInvokeExtension.kt @@ -8,5 +8,5 @@ class Foo { val x = 0 - fun foo() = x() + fun foo() = x() // should resolve to fun x } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt index 47deb73c006..81e849c5254 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt @@ -1,6 +1,6 @@ class A { - fun bar() = foo() + fun bar() = foo() // should resolve to invoke fun invoke() = this } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.txt index e470dc3e190..a9424bd87c9 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.txt @@ -4,8 +4,8 @@ FILE: implicitTypeOrder.kt super() } - public final fun bar(): { - ^bar #() + public final fun bar(): R|A| { + ^bar R|/foo|.R|/A.invoke|() } public final fun invoke(): R|A| { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt new file mode 100644 index 00000000000..187ebd5f683 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt @@ -0,0 +1,7 @@ +class Simple { + operator fun invoke(): String = "invoke" +} + +fun test(s: Simple) { + val result = s() +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.txt new file mode 100644 index 00000000000..66e16836aa6 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.txt @@ -0,0 +1,14 @@ +FILE: simple.kt + public final class Simple : R|kotlin/Any| { + public constructor(): R|Simple| { + super() + } + + public final operator fun invoke(): R|kotlin/String| { + ^invoke String(invoke) + } + + } + public final fun test(s: R|Simple|): R|kotlin/Unit| { + lval result: R|kotlin/String| = R|/s|.R|/Simple.invoke|() + } diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.kt b/compiler/fir/resolve/testData/resolve/functionTypes.kt index de0d6b0ae1e..d147e89102c 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.kt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.kt @@ -1,4 +1,4 @@ -fun simpleRun(f: (T) -> Unit): Unit = f() +fun simpleRun(f: (T) -> Unit): Unit = f(return) fun List.simpleMap(f: (T) -> R): R { diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.txt b/compiler/fir/resolve/testData/resolve/functionTypes.txt index 43e3ea86178..3f2ecccc3a7 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.txt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.txt @@ -1,6 +1,6 @@ FILE: functionTypes.kt public final fun simpleRun(f: R|kotlin/Function1|): R|kotlin/Unit| { - ^simpleRun #() + ^simpleRun R|/f|.R|FakeOverride|(^simpleRun Unit) } public final fun R|kotlin/collections/List|.simpleMap(f: R|kotlin/Function1|): R|R| { } 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 546990247a4..93ab0fada97 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -372,6 +372,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/implicitTypeOrder.kt"); } + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt"); + } + @TestMetadata("threeReceivers.kt") public void testThreeReceivers() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt"); diff --git a/compiler/testData/ir/irText/classes/outerClassAccess.fir.txt b/compiler/testData/ir/irText/classes/outerClassAccess.fir.txt index 6882ac64dd5..60bac96dae6 100644 --- a/compiler/testData/ir/irText/classes/outerClassAccess.fir.txt +++ b/compiler/testData/ir/irText/classes/outerClassAccess.fir.txt @@ -32,7 +32,7 @@ FILE fqName: fileName:/outerClassAccess.kt FUN name:test3 visibility:public modality:FINAL <> ($this:.Outer.Inner.Inner2) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Outer.Inner.Inner2 BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CALL 'public final fun foo (): kotlin.Unit declared in .Outer' type=kotlin.Unit origin=null 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 diff --git a/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt b/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt index 51a13c821a1..72cd6464f5d 100644 --- a/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt +++ b/compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.fir.txt @@ -42,7 +42,8 @@ FILE fqName: fileName:/augmentedAssignmentWithExpression.kt 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=IrErrorType value=1 + VAR name: type:.Host [val] + CALL 'public abstract fun invoke (): .Host declared in kotlin.Function0' type=.Host origin=null + $this: GET_VAR 'a: kotlin.Function0<.Host> declared in .test4' type=kotlin.Function0<.Host> origin=null + SET_VAR 'val : .Host [val] declared in .test4' type=.Host origin=null + CONST Int type=.Host value=1 diff --git a/compiler/testData/ir/irText/expressions/catchParameterAccess.fir.txt b/compiler/testData/ir/irText/expressions/catchParameterAccess.fir.txt index eda974e97c6..ed62269f611 100644 --- a/compiler/testData/ir/irText/expressions/catchParameterAccess.fir.txt +++ b/compiler/testData/ir/irText/expressions/catchParameterAccess.fir.txt @@ -1,10 +1,11 @@ FILE fqName: fileName:/catchParameterAccess.kt - FUN name:test visibility:public modality:FINAL <> (f:kotlin.Function0) returnType:kotlin.Nothing? + FUN name:test visibility:public modality:FINAL <> (f:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:f index:0 type:kotlin.Function0 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (f: kotlin.Function0): kotlin.Nothing? declared in ' - TRY type=kotlin.Nothing? - try: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + RETURN type=kotlin.Nothing from='public final fun test (f: kotlin.Function0): kotlin.Unit declared in ' + TRY type=kotlin.Unit + try: CALL 'public abstract fun invoke (): kotlin.Unit declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'f: kotlin.Function0 declared in .test' type=kotlin.Function0 origin=null CATCH parameter=val e: java.lang.Exception [val] declared in .test VAR name:e type:java.lang.Exception [val] THROW type=kotlin.Nothing diff --git a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt index 85871384156..6ab98840235 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt @@ -81,5 +81,5 @@ FILE fqName: fileName:/enumEntryAsReceiver.kt FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - + CALL 'public abstract fun invoke (): kotlin.String declared in kotlin.Function0' type=kotlin.String origin=null + $this: CALL 'public abstract fun (): kotlin.Function0 declared in .X' type=kotlin.Function0 origin=null diff --git a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt index ffce7b670b9..6470a4e3ed4 100644 --- a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt +++ b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt @@ -1,11 +1,12 @@ FILE fqName: fileName:/extFunInvokeAsFun.kt - FUN name:with1 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Function1) returnType:IrErrorType + FUN name:with1 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:receiver index:0 type:kotlin.Any? VALUE_PARAMETER name:block index:1 type:kotlin.Function1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun with1 (receiver: kotlin.Any?, block: kotlin.Function1): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'receiver: kotlin.Any? declared in .with1' type=kotlin.Any? origin=null + RETURN type=kotlin.Nothing from='public final fun with1 (receiver: kotlin.Any?, block: kotlin.Function1): kotlin.Unit declared in ' + CALL 'public abstract fun invoke (p1: kotlin.Any?): kotlin.Unit declared in kotlin.Function1' type=kotlin.Unit origin=null + $this: GET_VAR 'block: kotlin.Function1 declared in .with1' type=kotlin.Function1 origin=null + p1: GET_VAR 'receiver: kotlin.Any? declared in .with1' type=kotlin.Any? origin=null FUN name:with2 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Function1) returnType:IrErrorType VALUE_PARAMETER name:receiver index:0 type:kotlin.Any? VALUE_PARAMETER name:block index:1 type:kotlin.Function1 diff --git a/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt b/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt index 682d8527fb8..05ecee43e27 100644 --- a/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.fir.txt @@ -19,7 +19,8 @@ FILE fqName: fileName:/genericConstructorCallWithTypeArguments.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:T of kotlin.Array VALUE_PARAMETER name:it index:0 type:kotlin.Int BLOCK_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CALL 'public abstract fun invoke (): T of .testArray declared in kotlin.Function0' type=T of .testArray origin=null + $this: GET_VAR 'block: kotlin.Function0.testArray> [crossinline] declared in .testArray' type=kotlin.Function0.testArray> origin=null FUNCTION_REFERENCE 'local final fun (it: kotlin.Int): T of kotlin.Array declared in .testArray' type=kotlin.Function1 origin=LAMBDA CLASS CLASS name:Box modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Box diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt index 33f1cb45157..e1e12e68d6b 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt @@ -64,6 +64,6 @@ FILE fqName: fileName:/implicitCastToNonNull.kt $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ arg0: GET_VAR 'x: T of .test5 declared in .test5' type=T of .test5 origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'x: T of .test5 declared in .test5' type=T of .test5 origin=null - + then: CALL 'public abstract fun invoke (p1: S of .test5): kotlin.Unit declared in kotlin.Function1' type=kotlin.Unit origin=null + $this: GET_VAR 'fn: kotlin.Function1.test5, kotlin.Unit> declared in .test5' type=kotlin.Function1.test5, kotlin.Unit> origin=null + p1: GET_VAR 'x: T of .test5 declared in .test5' type=T of .test5 origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt index f00bb8a846d..49fca780a5b 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt @@ -76,9 +76,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt FUN name:test8 visibility:public modality:FINAL <> (a:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Function0 BLOCK_BODY - CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: CONSTRUCTOR_CALL 'public constructor () declared in .J' type=.J origin=null - r: CALL 'public open fun id (x: T of ?): T of ? declared in .J' type=IrErrorType origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CALL 'public open fun id (x: T of ?): T of ? declared in .J' type=kotlin.Function0 origin=null x: GET_VAR 'a: kotlin.Function0 declared in .test8' type=kotlin.Function0 origin=null FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt index bb3905d5da9..4aa6cbf0cfa 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt @@ -7,11 +7,12 @@ FILE fqName: fileName:/variableAsFunctionCall.kt BLOCK_BODY ERROR_CALL 'Unresolved reference: this#' type=kotlin.String FUNCTION_REFERENCE 'local final fun (): kotlin.Function0 declared in .k' type=kotlin.Function1, kotlin.Function0> origin=LAMBDA - FUN name:test1 visibility:public modality:FINAL <> (f:kotlin.Function0) returnType:IrErrorType + FUN name:test1 visibility:public modality:FINAL <> (f:kotlin.Function0) returnType:kotlin.Unit VALUE_PARAMETER name:f index:0 type:kotlin.Function0 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function0): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function0): kotlin.Unit declared in ' + CALL 'public abstract fun invoke (): kotlin.Unit declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'f: kotlin.Function0 declared in .test1' type=kotlin.Function0 origin=null FUN name:test2 visibility:public modality:FINAL <> (f:kotlin.Function1) returnType:IrErrorType VALUE_PARAMETER name:f index:0 type:kotlin.Function1 BLOCK_BODY @@ -22,9 +23,9 @@ FILE fqName: fileName:/variableAsFunctionCall.kt RETURN type=kotlin.Nothing from='public final fun test3 (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType CALL 'public final fun k (): kotlin.Function0 declared in ' type=kotlin.Function0 origin=null - FUN name:test4 visibility:public modality:FINAL <> (ns:kotlin.String?) returnType:IrErrorType + FUN name:test4 visibility:public modality:FINAL <> (ns:kotlin.String?) returnType:kotlin.String VALUE_PARAMETER name:ns index:0 type:kotlin.String? BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test4 (ns: kotlin.String?): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - + RETURN type=kotlin.Nothing from='public final fun test4 (ns: kotlin.String?): kotlin.String declared in ' + CALL 'public abstract fun invoke (): kotlin.String declared in kotlin.Function0' type=kotlin.String origin=null + $this: CALL 'public final fun k (): kotlin.Function0 declared in ' type=kotlin.Function0 origin=null diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.txt index fd7733da08e..c996eddf520 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.txt @@ -9,11 +9,12 @@ FILE fqName: fileName:/variableAsFunctionCallWithGenerics.kt BLOCK_BODY ERROR_CALL 'Unresolved reference: this#' type=IrErrorType FUNCTION_REFERENCE 'local final fun (): kotlin.Function0> declared in .' type=kotlin.Function1>, kotlin.Function0>> origin=LAMBDA - FUN name:testGeneric1 visibility:public modality:FINAL <> (x:kotlin.String) returnType:IrErrorType + FUN name:testGeneric1 visibility:public modality:FINAL <> (x:kotlin.String) returnType:T of VALUE_PARAMETER name:x index:0 type:kotlin.String BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun testGeneric1 (x: kotlin.String): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + RETURN type=kotlin.Nothing from='public final fun testGeneric1 (x: kotlin.String): T of declared in ' + CALL 'public abstract fun invoke (): T of declared in kotlin.Function0' type=T of origin=null + $this: CALL 'public final fun (): kotlin.Function0> declared in ' type=kotlin.Function0> origin=null PROPERTY name:kt26531Val visibility:public modality:FINAL [val] FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Function0> correspondingProperty: PROPERTY name:kt26531Val visibility:public modality:FINAL [val] @@ -25,8 +26,8 @@ FILE fqName: fileName:/variableAsFunctionCallWithGenerics.kt RETURN type=kotlin.Nothing from='local final fun (): kotlin.Function0> declared in .' ERROR_CALL 'Unresolved reference: this#' type=IrErrorType FUNCTION_REFERENCE 'local final fun (): kotlin.Function0> declared in .' type=kotlin.Function0>> origin=ANONYMOUS_FUNCTION - FUN name:kt26531 visibility:public modality:FINAL <> () returnType:IrErrorType + FUN name:kt26531 visibility:public modality:FINAL <> () returnType:T of BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun kt26531 (): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - + RETURN type=kotlin.Nothing from='public final fun kt26531 (): T of declared in ' + CALL 'public abstract fun invoke (): T of declared in kotlin.Function0' type=T of origin=null + $this: CALL 'public final fun (): kotlin.Function0> declared in ' type=kotlin.Function0> origin=null diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt index b75400185b9..16619582a65 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt @@ -83,25 +83,26 @@ 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.Unit origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Int 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.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.Unit origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Int origin=null receiver: GET_VAR 'fooImpl: .IFoo declared in .test' type=.IFoo origin=null 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.Unit origin=null + CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Int origin=null receiver: GET_VAR 'invokeImpl: .IInvoke declared in .test' type=.IInvoke origin=null 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 + CALL 'public open fun invoke (): kotlin.Int declared in .IInvoke' type=kotlin.Int origin=null + $this: CALL 'public open fun (): .B declared in .IFoo' type=.B origin=null 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/regressions/newInference/fixationOrder1.fir.txt b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt index 029b77d0a59..44bc85f8105 100644 --- a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt +++ b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt @@ -39,7 +39,7 @@ FILE fqName: fileName:/fixationOrder1.kt : x: CONST String type=kotlin.String value="" y: CONST Int type=kotlin.Int value=1 - f: CALL 'public final fun foo (): kotlin.Function1.foo, Y of .foo> declared in ' type=kotlin.Function1 origin=null + f: CALL 'public final fun foo (): kotlin.Function1.foo, Y of .foo> declared in ' type=kotlin.Function1 origin=null : : FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String diff --git a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt index 866817045ea..0cdad186de1 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt @@ -68,32 +68,32 @@ FILE fqName: fileName:/intersectionType2_NI.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:IrErrorType + FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:T of .run TYPE_PARAMETER name:T index:0 variance: superTypes:[] VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.run> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun run (fn: kotlin.Function0.run>): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN name:foo visibility:public modality:FINAL <> () returnType:IrErrorType + RETURN type=kotlin.Nothing from='public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' + CALL 'public abstract fun invoke (): T of .run declared in kotlin.Function0' type=T of .run origin=null + $this: GET_VAR 'fn: kotlin.Function0.run> declared in .run' type=kotlin.Function0.run> origin=null + FUN name:foo visibility:public modality:FINAL <> () returnType:.B BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): IrErrorType declared in ' - CALL 'public final fun run (fn: kotlin.Function0.run>): IrErrorType declared in ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun foo (): .B declared in ' + CALL 'public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' type=.B origin=null : - fn: BLOCK type=IrErrorType origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:IrErrorType + fn: BLOCK type=kotlin.Function0<.B> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.B BLOCK_BODY - VAR name:mm type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: B#' type=IrErrorType - VAR name:nn type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: C#' type=IrErrorType - VAR name:c type:IrErrorType [val] - WHEN type=IrErrorType origin=IF - BRANCH - if: CONST Boolean type=IrErrorType value=true - then: ERROR_CALL 'Unresolved reference: mm#' type=IrErrorType + VAR name:mm type:.B [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + VAR name:nn type:.C [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + VAR name:c type:.B [val] + WHEN type=.B origin=IF BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: ERROR_CALL 'Unresolved reference: nn#' type=IrErrorType - ERROR_CALL 'Unresolved reference: c#' type=IrErrorType - FUNCTION_REFERENCE 'local final fun (): IrErrorType declared in .foo' type=IrErrorType origin=LAMBDA - + then: GET_VAR 'val mm: .B [val] declared in .foo.' type=.B origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val nn: .C [val] declared in .foo.' type=.C origin=null + GET_VAR 'val c: .B [val] declared in .foo.' type=.B origin=null + FUNCTION_REFERENCE 'local final fun (): .B declared in .foo' type=kotlin.Function0<.B> origin=LAMBDA diff --git a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt index 0cf45e1b37a..68c64e7c750 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt @@ -68,31 +68,32 @@ FILE fqName: fileName:/intersectionType2_OI.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:IrErrorType + FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:T of .run TYPE_PARAMETER name:T index:0 variance: superTypes:[] VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.run> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun run (fn: kotlin.Function0.run>): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN name:foo visibility:public modality:FINAL <> () returnType:IrErrorType + RETURN type=kotlin.Nothing from='public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' + CALL 'public abstract fun invoke (): T of .run declared in kotlin.Function0' type=T of .run origin=null + $this: GET_VAR 'fn: kotlin.Function0.run> declared in .run' type=kotlin.Function0.run> origin=null + FUN name:foo visibility:public modality:FINAL <> () returnType:.B BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): IrErrorType declared in ' - CALL 'public final fun run (fn: kotlin.Function0.run>): IrErrorType declared in ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun foo (): .B declared in ' + CALL 'public final fun run (fn: kotlin.Function0.run>): T of .run declared in ' type=.B origin=null : - fn: BLOCK type=IrErrorType origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:IrErrorType + fn: BLOCK type=kotlin.Function0<.B> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:.B BLOCK_BODY - VAR name:mm type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: B#' type=IrErrorType - VAR name:nn type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: C#' type=IrErrorType - VAR name:c type:IrErrorType [val] - WHEN type=IrErrorType origin=IF - BRANCH - if: CONST Boolean type=IrErrorType value=true - then: ERROR_CALL 'Unresolved reference: mm#' type=IrErrorType + VAR name:mm type:.B [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + VAR name:nn type:.C [val] + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + VAR name:c type:.B [val] + WHEN type=.B origin=IF BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: ERROR_CALL 'Unresolved reference: nn#' type=IrErrorType - ERROR_CALL 'Unresolved reference: c#' type=IrErrorType - FUNCTION_REFERENCE 'local final fun (): IrErrorType declared in .foo' type=IrErrorType origin=LAMBDA + then: GET_VAR 'val mm: .B [val] declared in .foo.' type=.B origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val nn: .C [val] declared in .foo.' type=.C origin=null + GET_VAR 'val c: .B [val] declared in .foo.' type=.B origin=null + FUNCTION_REFERENCE 'local final fun (): .B declared in .foo' type=kotlin.Function0<.B> origin=LAMBDA