From de50f8aef3e3c281536d4601e006cd7b61b26e36 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 23 Dec 2019 15:56:50 +0300 Subject: [PATCH] FIR resolve: add partial support of extension lambda calls Here we introduce ONLY_IMPLICIT_RECEIVER tower level to support extension lambda calls on local variables, and soften extension receiver checks to make such extensions visible & applicable. Also here we try to map arguments twice for functional types --- .../fir/resolve/calls/FirTowerResolver.kt | 43 +++++++++++++------ .../kotlin/fir/resolve/calls/ResolverParts.kt | 30 ++++++++++--- .../fir/resolve/calls/TowerDataConsumers.kt | 5 ++- .../kotlin/fir/resolve/calls/TowerLevels.kt | 25 ++++++++--- .../expresssions/invoke/doubleBrackets.kt | 3 ++ .../expresssions/invoke/doubleBrackets.txt | 10 +++++ .../resolve/expresssions/invoke/inBrackets.kt | 4 +- .../expresssions/invoke/inBrackets.txt | 4 +- .../invoke/propertyWithExtensionType.kt | 10 +++++ .../invoke/propertyWithExtensionType.txt | 24 +++++++++++ .../expresssions/invoke/threeReceivers.kt | 2 +- .../expresssions/invoke/threeReceivers.txt | 2 +- .../expresssions/lambdaWithReceiver.kt | 4 +- .../expresssions/lambdaWithReceiver.txt | 4 +- .../resolve/testData/resolve/functionTypes.kt | 2 +- .../testData/resolve/functionTypes.txt | 2 +- .../problems/invokeOfLambdaWithReceiver.kt | 12 +++++- .../problems/invokeOfLambdaWithReceiver.txt | 15 ++++++- .../fir/FirDiagnosticsTestGenerated.java | 10 +++++ ...DiagnosticsWithLightTreeTestGenerated.java | 10 +++++ .../diagnostics/tests/Builders.fir.kt | 4 +- .../tests/ExtensionCallInvoke.fir.kt | 6 +-- .../FreeFunctionCalledAsExtension.fir.kt | 2 +- .../tests/FunctionCalleeExpressions.fir.kt | 2 +- .../callableReference/resolve/kt10036.fir.kt | 2 +- .../tests/deprecated/typeUsage.fir.kt | 2 +- ...CreatePackageTypeForEnumEntry_after.fir.kt | 8 ++-- ...reatePackageTypeForEnumEntry_before.fir.kt | 8 ++-- .../tests/extensions/kt1875.fir.kt | 2 +- .../tests/extensions/variableInvoke.fir.kt | 8 ++-- .../diagnostics/tests/inference/kt3184.fir.kt | 2 +- .../tests/inference/regressions/kt2514.fir.kt | 2 +- .../regressions/kt2841_it_this.fir.kt | 2 +- .../inference/regressions/kt2841_this.fir.kt | 2 +- ...umentPassedToLocalExtensionFunction.fir.kt | 2 +- .../diagnostics/tests/inline/invoke.fir.kt | 8 ++-- .../tests/inline/propagation.fir.kt | 12 +++--- .../tests/inline/property/invoke.fir.kt | 4 +- .../diagnostics/tests/inline/sam.fir.kt | 8 ++-- .../diagnostics/tests/labels/kt4586.fir.kt | 2 +- ...elReferencesInsideObjectExpressions.fir.kt | 2 +- .../tests/operatorsOverloading/kt13330.fir.kt | 2 +- .../invokeInFunctionClass.fir.kt | 6 +-- .../tests/regressions/Jet121.fir.kt | 2 +- .../tests/regressions/kt3731.fir.kt | 6 +-- .../tests/regressions/kt442.fir.kt | 2 +- .../tests/regressions/kt604.fir.kt | 2 +- .../tests/regressions/kt9808.fir.kt | 2 +- .../propertyWithExtensionTypeInvoke.fir.kt | 2 +- ...tyWithTwoCorrespondingFunctionTypes.fir.kt | 2 +- .../dslMarker/dslMarkerOnTypealias.fir.kt | 14 +++--- .../dslMarkerWithTypealiasRecursion.fir.kt | 8 ++-- .../resolve/implicitReceiverProperty.fir.kt | 6 +-- .../resolve/invoke/implicitInvoke.fir.kt | 8 ++-- .../resolve/invoke/invokeAndSmartCast.fir.kt | 4 +- ...AsMemberExtensionToExplicitReceiver.fir.kt | 2 +- ...OnVariableWithExtensionFunctionType.fir.kt | 16 +++---- .../tests/resolve/invoke/kt9805.fir.kt | 4 +- .../resolve/invoke/valNamedInvoke.fir.kt | 4 +- .../invoke/wrongInvokeExtension.fir.kt | 4 +- .../priority/invokeExtensionVsOther.fir.kt | 2 +- .../diagnostics/tests/safeCall.fir.kt | 2 +- .../expressions/extFunInvokeAsFun.fir.txt | 7 +-- .../expressions/extFunSafeInvoke.fir.txt | 11 ++--- .../variableAsFunctionCall.fir.txt | 7 +-- 65 files changed, 292 insertions(+), 144 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt create mode 100644 compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.txt create mode 100644 compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt create mode 100644 compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.txt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index aa55a34fd98..21e51c70ccd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -9,16 +9,15 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.isInner import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents -import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.EMPTY -import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.TOWER_LEVEL +import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.* import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NONE import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope enum class TowerDataKind { - EMPTY, - TOWER_LEVEL + EMPTY, // Corresponds to stub tower level which is replaced by receiver-related level + TOWER_LEVEL // Corresponds to real tower level which may process elements itself } class FirTowerResolver( @@ -46,10 +45,23 @@ class FirTowerResolver( // } towerDataConsumer.consume( TOWER_LEVEL, - MemberScopeTowerLevel(session, components, implicitReceiverValue, scopeSession = components.scopeSession), + MemberScopeTowerLevel(session, components, dispatchReceiver = implicitReceiverValue, scopeSession = components.scopeSession), group++ ) + // class Foo { + // fun foo(block: Foo.() -> Unit) { + // block() + // } + // } + // invokeExtension on local variable + towerDataConsumer.consume( + EMPTY, + TowerScopeLevel.OnlyImplicitReceiver(implicitReceiverValue), + group++ + ) + //TowerData.OnlyImplicitReceiver(implicitReceiver).process()?.let { return it } + // Same receiver is dispatch & extension // class Foo { // fun Foo.bar() {} @@ -57,18 +69,23 @@ class FirTowerResolver( // } towerDataConsumer.consume( TOWER_LEVEL, - MemberScopeTowerLevel(session, components, implicitReceiverValue, implicitReceiverValue, components.scopeSession), + MemberScopeTowerLevel( + session, components, + dispatchReceiver = implicitReceiverValue, + implicitExtensionReceiver = implicitReceiverValue, + scopeSession = components.scopeSession + ), group++ ) - // Local scope extensions via implicit receiver - // class Foo { - // fun test() { - // fun Foo.bar() {} - // bar() - // } - // } for (scope in nonEmptyLocalScopes) { + // Local scope extensions via implicit receiver + // class Foo { + // fun test() { + // fun Foo.bar() {} + // bar() + // } + // } towerDataConsumer.consume( TOWER_LEVEL, ScopeTowerLevel(session, components, scope, implicitExtensionReceiver = implicitReceiverValue), diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt index aec2d4719eb..bbd9e3a19a2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt @@ -8,7 +8,9 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol @@ -17,10 +19,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef -import org.jetbrains.kotlin.fir.types.coneTypeSafe +import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.load.java.JavaVisibilities import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -84,7 +83,11 @@ internal sealed class CheckReceivers : ResolutionStage() { override fun Candidate.getReceiverType(): ConeKotlinType? { val callableSymbol = symbol as? FirCallableSymbol<*> ?: return null val callable = callableSymbol.fir - return (callable.receiverTypeRef as FirResolvedTypeRef?)?.type + val receiverType = (callable.receiverTypeRef as FirResolvedTypeRef?)?.type + if (receiverType != null) return receiverType + val returnTypeRef = callable.returnTypeRef as? FirResolvedTypeRef ?: return null + if (!returnTypeRef.isExtensionFunctionType()) return null + return (returnTypeRef.type.typeArguments.firstOrNull() as? ConeTypedProjection)?.type } } @@ -136,6 +139,23 @@ internal object MapArguments : ResolutionStage() { override suspend fun check(candidate: Candidate, sink: CheckerSink, callInfo: CallInfo) { val symbol = candidate.symbol as? FirFunctionSymbol<*> ?: return sink.reportApplicability(CandidateApplicability.HIDDEN) val function = symbol.fir + if (candidate.dispatchReceiverValue?.type?.isBuiltinFunctionalType == true) { + // We don't know is it extension function or not due to lack of annotations + // So we have to check both variants, with receiver and without it + // TODO: remove this double-check after KT-30066 + val lambdaExtensionReceiver = + (callInfo.explicitReceiver as? FirQualifiedAccess)?.extensionReceiver?.takeIf { it !is FirNoReceiverExpression } + ?: (candidate.implicitExtensionReceiverValue as? ImplicitReceiverValue)?.receiverExpression + val processorWithReceiver = FirCallArgumentsProcessor( + function, + listOfNotNull(lambdaExtensionReceiver) + callInfo.arguments + ) + val mappingResult = processorWithReceiver.process() + candidate.argumentMapping = mappingResult.argumentMapping + if (mappingResult.isSuccess) { + return + } + } val processor = FirCallArgumentsProcessor(function, callInfo.arguments) val mappingResult = processor.process() candidate.argumentMapping = mappingResult.argumentMapping diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerDataConsumers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerDataConsumers.kt index 6b6953bc945..b3864ce0780 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerDataConsumers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerDataConsumers.kt @@ -173,9 +173,11 @@ class ExplicitReceiverTowerDataConsumer>( ): ProcessorAction { if (skipGroup(group)) return ProcessorAction.NEXT return when (kind) { - TowerDataKind.EMPTY -> + TowerDataKind.EMPTY -> { MemberScopeTowerLevel( session, resultCollector.components, explicitReceiver, + implicitExtensionReceiver = (towerScopeLevel as? TowerScopeLevel.OnlyImplicitReceiver)?.implicitReceiverValue, + invokeOnly = towerScopeLevel is TowerScopeLevel.OnlyImplicitReceiver, scopeSession = candidateFactory.bodyResolveComponents.scopeSession ).processElementsByName( token, @@ -183,6 +185,7 @@ class ExplicitReceiverTowerDataConsumer>( explicitReceiver = null, processor = EmptyKindTowerProcessor(group) ) + } TowerDataKind.TOWER_LEVEL -> { if (token == TowerScopeLevel.Token.Objects) return ProcessorAction.NEXT towerScopeLevel.processElementsByName( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt index 34d89c25b49..b1b241d74a4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/TowerLevels.kt @@ -20,8 +20,10 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.types.isExtensionFunctionType import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.addToStdlib.cast interface TowerScopeLevel { @@ -48,7 +50,7 @@ interface TowerScopeLevel { ): ProcessorAction } - object Empty : TowerScopeLevel { + abstract class StubTowerScopeLevel : TowerScopeLevel { override fun > processElementsByName( token: Token, name: Name, @@ -56,6 +58,10 @@ interface TowerScopeLevel { processor: TowerScopeLevelProcessor ): ProcessorAction = ProcessorAction.NEXT } + + object Empty : StubTowerScopeLevel() + + class OnlyImplicitReceiver(val implicitReceiverValue: ImplicitReceiverValue<*>) : StubTowerScopeLevel() } abstract class SessionBasedTowerLevel(val session: FirSession) : TowerScopeLevel { @@ -70,8 +76,10 @@ abstract class SessionBasedTowerLevel(val session: FirSession) : TowerScopeLevel } protected fun FirCallableSymbol<*>.hasConsistentExtensionReceiver(extensionReceiver: ReceiverValue?): Boolean { - val hasExtensionReceiver = hasExtensionReceiver() - return hasExtensionReceiver == (extensionReceiver != null) + return when { + extensionReceiver != null -> hasExtensionReceiver() + else -> fir.receiverTypeRef == null + } } } @@ -86,6 +94,7 @@ class MemberScopeTowerLevel( val bodyResolveComponents: BodyResolveComponents, val dispatchReceiver: ReceiverValue, val implicitExtensionReceiver: ImplicitReceiverValue<*>? = null, + val invokeOnly: Boolean = false, val scopeSession: ScopeSession ) : SessionBasedTowerLevel(session) { private fun > processMembers( @@ -97,7 +106,7 @@ class MemberScopeTowerLevel( val extensionReceiver = implicitExtensionReceiver ?: explicitExtensionReceiver val scope = dispatchReceiver.scope(session, scopeSession) ?: return ProcessorAction.NEXT if (scope.processScopeMembers { candidate -> - if (candidate is FirCallableSymbol<*> && candidate.hasConsistentExtensionReceiver(extensionReceiver)) { + if (candidate is FirCallableSymbol<*> && (invokeOnly || candidate.hasConsistentExtensionReceiver(extensionReceiver))) { // NB: we do not check dispatchReceiverValue != null here, // because of objects & constructors (see comments in dispatchReceiverValue() implementation) output.consumeCandidate(candidate, candidate.dispatchReceiverValue(), implicitExtensionReceiver) @@ -120,6 +129,9 @@ class MemberScopeTowerLevel( explicitReceiver: ExpressionReceiverValue?, processor: TowerScopeLevel.TowerScopeLevelProcessor ): ProcessorAction { + if (invokeOnly && (token != TowerScopeLevel.Token.Functions || name != OperatorNameConventions.INVOKE)) { + return ProcessorAction.NEXT + } val explicitExtensionReceiver = if (dispatchReceiver == explicitReceiver) null else explicitReceiver return when (token) { TowerScopeLevel.Token.Properties -> processMembers(processor, explicitExtensionReceiver) { symbol -> @@ -277,4 +289,7 @@ fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassD return ClassDispatchReceiverValue(symbol) } -private fun FirCallableSymbol<*>.hasExtensionReceiver(): Boolean = this.fir.receiverTypeRef != null +private fun FirCallableSymbol<*>.hasExtensionReceiver(): Boolean { + if (fir.receiverTypeRef != null) return true + return fir.returnTypeRef.isExtensionFunctionType() +} diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt new file mode 100644 index 00000000000..2c1c336f3d3 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt @@ -0,0 +1,3 @@ +fun String.k(): () -> String = { -> this } + +fun test() = "hello".k()() \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.txt new file mode 100644 index 00000000000..5a15c9a326f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.txt @@ -0,0 +1,10 @@ +FILE: doubleBrackets.kt + public final fun R|kotlin/String|.k(): R|() -> kotlin/String| { + ^k fun (): R|kotlin/String| { + this@R|/k| + } + + } + public final fun test(): R|kotlin/String| { + ^test String(hello).R|/k|().R|FakeOverride|() + } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.kt index c0a6b401adb..363c262ad17 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.kt @@ -1,4 +1,4 @@ fun test(e: Int.() -> String) { - val s = 3.e() - val ss = 3.(e)() + val s = 3.e() + val ss = 3.(e)() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.txt index a70c058ed5a..f19678b06ce 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/inBrackets.txt @@ -1,5 +1,5 @@ FILE: inBrackets.kt public final fun test(e: R|kotlin/Int.() -> kotlin/String|): R|kotlin/Unit| { - lval s: = Int(3).#() - lval ss: = Int(3).#() + lval s: R|kotlin/String| = Int(3).R|/e|.R|FakeOverride|() + lval ss: R|kotlin/String| = Int(3).R|/e|.R|FakeOverride|() } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt new file mode 100644 index 00000000000..e9d5bb869a8 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt @@ -0,0 +1,10 @@ +class A(val x: (String.() -> Unit)?, val y: (String.() -> Int)) + +fun test(a: A) { + if (a.x != null) { + val b = a.x + "".b() + } + val c = a.y + val d = "".c() +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.txt new file mode 100644 index 00000000000..9f9f1906fee --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.txt @@ -0,0 +1,24 @@ +FILE: propertyWithExtensionType.kt + public final class A : R|kotlin/Any| { + public constructor(x: R|kotlin/String.() -> kotlin/Unit|, y: R|kotlin/String.() -> kotlin/Int|): R|A| { + super() + } + + public final val x: R|kotlin/String.() -> kotlin/Unit| = R|/x| + public get(): R|kotlin/String.() -> kotlin/Unit| + + public final val y: R|kotlin/String.() -> kotlin/Int| = R|/y| + public get(): R|kotlin/String.() -> kotlin/Int| + + } + public final fun test(a: R|A|): R|kotlin/Unit| { + when () { + !=(R|/a|.R|/A.x|, Null(null)) -> { + lval b: R|kotlin/String.() -> kotlin/Unit| = R|/a|.R|/A.x| + String().R|/b|.R|FakeOverride|() + } + } + + lval c: R|kotlin/String.() -> kotlin/Int| = R|/a|.R|/A.y| + lval d: R|kotlin/Int| = String().R|/c|.R|FakeOverride|() + } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt index 8c3918b5a7f..9ab37a82079 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt @@ -12,6 +12,6 @@ class Foo { val Buz.foobar: Bar get() = Bar() fun FooBar.chk(buz: Buz) { - buz.foobar() + buz.foobar() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.txt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.txt index 8a1be596659..8c8ce2b21ad 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.txt @@ -32,7 +32,7 @@ FILE: threeReceivers.kt } public final fun R|FooBar|.chk(buz: R|Buz|): R|kotlin/Unit| { - R|/buz|.#() + ((this@R|/Foo|, R|/buz|).R|/Foo.foobar|, this@R|/Foo.chk|).R|/Bar.invoke|() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt index 604b2f69eda..d38dbf0d514 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt @@ -3,11 +3,11 @@ interface A { } fun myWith(receiver: T, block: T.() -> Unit) { - receiver.block() + receiver.block() } fun T.myApply(block: T.() -> Unit) { - this.block() + this.block() } fun withA(block: A.() -> Unit) {} diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt index 8f4156205c1..4dd147d1194 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.txt @@ -4,10 +4,10 @@ FILE: lambdaWithReceiver.kt } public final fun myWith(receiver: R|T|, block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { - R|/receiver|.#() + R|/receiver|.R|/block|.R|FakeOverride|() } public final fun R|T|.myApply(block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { - this@R|/myApply|.#() + this@R|/myApply|.R|/block|.R|FakeOverride|() } public final fun withA(block: R|A.() -> kotlin/Unit|): R|kotlin/Unit| { } diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.kt b/compiler/fir/resolve/testData/resolve/functionTypes.kt index ce21d01bd71..d147e89102c 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.kt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.kt @@ -4,7 +4,7 @@ fun List.simpleMap(f: (T) -> R): R { } -fun simpleWith(t: T, f: T.() -> Unit): Unit = t.f() +fun simpleWith(t: T, f: T.() -> Unit): Unit = t.f() interface KMutableProperty1 : KProperty1, KMutableProperty diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.txt b/compiler/fir/resolve/testData/resolve/functionTypes.txt index 8033d060184..127a19df087 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.txt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.txt @@ -5,7 +5,7 @@ FILE: functionTypes.kt public final fun R|kotlin/collections/List|.simpleMap(f: R|(T) -> R|): R|R| { } public final fun simpleWith(t: R|T|, f: R|T.() -> kotlin/Unit|): R|kotlin/Unit| { - ^simpleWith R|/t|.#() + ^simpleWith R|/t|.R|/f|.R|FakeOverride|() } public abstract interface KMutableProperty1 : R|KProperty1|, R|KMutableProperty| { } diff --git a/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.kt b/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.kt index 64ba4bfcd6d..5a76b07fb06 100644 --- a/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.kt +++ b/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.kt @@ -1,5 +1,15 @@ interface A fun test(a: A, block: A.() -> Int) { - a.block() + a.block() +} + +fun A.otherTest(block: A.() -> Int) { + block() +} + +class B { + fun anotherTest(block: B.() -> Int) { + block() + } } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.txt b/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.txt index 7965dac87a3..fff1d35a17b 100644 --- a/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/problems/invokeOfLambdaWithReceiver.txt @@ -2,5 +2,18 @@ FILE: invokeOfLambdaWithReceiver.kt public abstract interface A : R|kotlin/Any| { } public final fun test(a: R|A|, block: R|A.() -> kotlin/Int|): R|kotlin/Unit| { - R|/a|.#() + R|/a|.R|/block|.R|FakeOverride|() + } + public final fun R|A|.otherTest(block: R|A.() -> kotlin/Int|): R|kotlin/Unit| { + (R|/block|, this@R|/otherTest|).R|FakeOverride|() + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + public final fun anotherTest(block: R|B.() -> kotlin/Int|): R|kotlin/Unit| { + (R|/block|, this@R|/B|).R|FakeOverride|() + } + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 172e4af41eb..6f983854fa1 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -654,6 +654,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/expresssions/invoke"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("doubleBrackets.kt") + public void testDoubleBrackets() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt"); + } + @TestMetadata("explicitReceiver.kt") public void testExplicitReceiver() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.kt"); @@ -694,6 +699,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.kt"); } + @TestMetadata("propertyWithExtensionType.kt") + public void testPropertyWithExtensionType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 529eb37a93b..6e460523d1d 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -654,6 +654,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/expresssions/invoke"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("doubleBrackets.kt") + public void testDoubleBrackets() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt"); + } + @TestMetadata("explicitReceiver.kt") public void testExplicitReceiver() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.kt"); @@ -694,6 +699,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.kt"); } + @TestMetadata("propertyWithExtensionType.kt") + public void testPropertyWithExtensionType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt"); diff --git a/compiler/testData/diagnostics/tests/Builders.fir.kt b/compiler/testData/diagnostics/tests/Builders.fir.kt index dd611744660..98131f69a04 100644 --- a/compiler/testData/diagnostics/tests/Builders.fir.kt +++ b/compiler/testData/diagnostics/tests/Builders.fir.kt @@ -70,7 +70,7 @@ abstract class Tag(val name : String) : Element() { val attributes = HashMap() protected fun initTag(tag : T, init : T.() -> Unit) : T { - tag.init() + tag.init() children.add(tag) return tag } @@ -143,7 +143,7 @@ class A() : BodyTag("a") { fun html(init : HTML.() -> Unit) : HTML { val html = HTML() - html.init() + html.init() return html } diff --git a/compiler/testData/diagnostics/tests/ExtensionCallInvoke.fir.kt b/compiler/testData/diagnostics/tests/ExtensionCallInvoke.fir.kt index a4092148fba..bc32e7c13c4 100644 --- a/compiler/testData/diagnostics/tests/ExtensionCallInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/ExtensionCallInvoke.fir.kt @@ -1,7 +1,7 @@ fun bar(doIt: Int.() -> Int) { - 1.doIt() - 1?.doIt() + 1.doIt() + 1?.doIt() val i: Int? = 1 i.doIt() - i?.doIt() + i?.doIt() } diff --git a/compiler/testData/diagnostics/tests/FreeFunctionCalledAsExtension.fir.kt b/compiler/testData/diagnostics/tests/FreeFunctionCalledAsExtension.fir.kt index 22b2715d38f..658970e217d 100644 --- a/compiler/testData/diagnostics/tests/FreeFunctionCalledAsExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/FreeFunctionCalledAsExtension.fir.kt @@ -9,5 +9,5 @@ interface A : (String) -> Unit {} fun foo(a: @ExtensionFunctionType A) { // @Extension annotation on an unrelated type shouldn't have any effect on this diagnostic. // Only kotlin.Function{n} type annotated with @Extension should - "".a() + "".a() } diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt index ba26cc68507..732cc6a9d27 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt @@ -26,7 +26,7 @@ fun fooT2() : (t : T) -> T { fun main(args : Array) { args.foo()() args.foo1()() - a.foo1()() + a.foo1()() a.foo1()(a) args.foo1()(1) diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.fir.kt index da79d5657c9..3753baea342 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt10036.fir.kt @@ -9,7 +9,7 @@ class OverloadTest { object Literal inline fun OverloadTest.overload(value: T?, function: OverloadTest.(T) -> Unit) { - if (value == null) foo(Literal) else function(value) + if (value == null) foo(Literal) else function(value) } // Overload resolution ambiguity diff --git a/compiler/testData/diagnostics/tests/deprecated/typeUsage.fir.kt b/compiler/testData/diagnostics/tests/deprecated/typeUsage.fir.kt index 992e7825664..b32b9120dd3 100644 --- a/compiler/testData/diagnostics/tests/deprecated/typeUsage.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/typeUsage.fir.kt @@ -29,7 +29,7 @@ class Properties { fun param(param: Obsolete) { param.use() } -fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().param() } +fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().param() } fun funcParamParam(param: (Obsolete)->Unit) { param(Obsolete()) } fun funcParamRetVal(param: ()->Obsolete) { param() } diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.fir.kt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.fir.kt index 6c4f3f5778a..8df7a9447ca 100644 --- a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.fir.kt +++ b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.fir.kt @@ -9,8 +9,8 @@ enum class E { val foo: Any.() -> Unit = {} -fun f1() = E.FIRST.foo() -fun f2() = E.FIRST.(foo)() -fun f3() = E.SECOND.foo() -fun f4() = E.SECOND.(foo)() +fun f1() = E.FIRST.foo() +fun f2() = E.FIRST.(foo)() +fun f3() = E.SECOND.foo() +fun f4() = E.SECOND.(foo)() fun f5() = E.SECOND.A() diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.fir.kt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.fir.kt index 97262b0cd34..c3119941ccc 100644 --- a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.fir.kt +++ b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.fir.kt @@ -9,8 +9,8 @@ enum class E { val foo: Any.() -> Unit = {} -fun f1() = E.FIRST.foo() -fun f2() = E.FIRST.(foo)() -fun f3() = E.SECOND.foo() -fun f4() = E.SECOND.(foo)() +fun f1() = E.FIRST.foo() +fun f2() = E.FIRST.(foo)() +fun f3() = E.SECOND.foo() +fun f4() = E.SECOND.(foo)() fun f5() = E.SECOND.A() diff --git a/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt b/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt index 0ea80d168cc..d96ef602126 100644 --- a/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/kt1875.fir.kt @@ -3,7 +3,7 @@ package kt1875 -fun foo(a : Int?, b : Int.(Int)->Int) = a?.b(1) //unnecessary safe call warning +fun foo(a : Int?, b : Int.(Int)->Int) = a?.b(1) //unnecessary safe call warning interface T { val f : ((i: Int) -> Unit)? diff --git a/compiler/testData/diagnostics/tests/extensions/variableInvoke.fir.kt b/compiler/testData/diagnostics/tests/extensions/variableInvoke.fir.kt index 831c40af196..f63402666e6 100644 --- a/compiler/testData/diagnostics/tests/extensions/variableInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/variableInvoke.fir.kt @@ -1,11 +1,11 @@ class A(foo: Int.() -> Unit) { init { - 4.foo() + 4.foo() } } fun test(foo: Int.(String) -> Unit) { - 4.foo("") - 4.foo(p1 = "") - 4.foo(p2 = "") + 4.foo("") + 4.foo(p1 = "") + 4.foo(p2 = "") } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt3184.fir.kt b/compiler/testData/diagnostics/tests/inference/kt3184.fir.kt index db51502b046..c0565f6c952 100644 --- a/compiler/testData/diagnostics/tests/inference/kt3184.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt3184.fir.kt @@ -4,7 +4,7 @@ package a import java.util.HashMap private fun test(value: T, extf: String.(value: T)->Unit) { - "".extf(value) + "".extf(value) } fun main() { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2514.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2514.fir.kt index 1dff03baa7a..090534551cd 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2514.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2514.fir.kt @@ -4,7 +4,7 @@ package kt2514 //+JDK import java.io.Closeable -fun Thread.use(block: Thread.() -> T): T = block() +fun Thread.use(block: Thread.() -> T): T = block() fun T.use(block: (T)-> R) : R = block(this) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2841_it_this.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2841_it_this.fir.kt index b245c6ccfb8..0ddd3367e39 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2841_it_this.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2841_it_this.fir.kt @@ -7,7 +7,7 @@ interface Closeable { class C : Closeable public inline fun use(t: T, block: T.(T)-> R) : R { - return t.block(t) + return t.block(t) } fun test() { diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2841_this.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2841_this.fir.kt index 166765b55a6..ad85125cb40 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2841_this.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2841_this.fir.kt @@ -7,7 +7,7 @@ interface Closeable { class C : Closeable public inline fun T.use(block: T.()-> R) : R { - return this.block() + return this.block() } fun test() { diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/wrongArgumentPassedToLocalExtensionFunction.fir.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/wrongArgumentPassedToLocalExtensionFunction.fir.kt index 3a3c8c81dea..71c1e1b753b 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/wrongArgumentPassedToLocalExtensionFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/wrongArgumentPassedToLocalExtensionFunction.fir.kt @@ -15,7 +15,7 @@ fun Int.test(f: String.(Int) -> Unit) { f("", 0) f("") with("") { - f(0) + f(0) f(0.0) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/invoke.fir.kt b/compiler/testData/diagnostics/tests/inline/invoke.fir.kt index 45b96b57bbe..0519b58bddf 100644 --- a/compiler/testData/diagnostics/tests/inline/invoke.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/invoke.fir.kt @@ -5,8 +5,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { s.invoke(11) s invoke 11 - 11.ext(11) - 11 ext 11 + 11.ext(11) + 11 ext 11 } inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { @@ -14,8 +14,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.( s.invoke(11) s invoke 11 - 11.ext(11) - 11 ext 11 + 11.ext(11) + 11 ext 11 } inline fun Function1.inlineExt() { diff --git a/compiler/testData/diagnostics/tests/inline/propagation.fir.kt b/compiler/testData/diagnostics/tests/inline/propagation.fir.kt index 3faba489acd..812ad41f724 100644 --- a/compiler/testData/diagnostics/tests/inline/propagation.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/propagation.fir.kt @@ -6,8 +6,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { } inline fun inlineFunWithInvokeClosure(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> s(p)}, { p -> this.ext(p)}) - subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) } //No inline @@ -17,8 +17,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, noinline e } inline fun inlineFunWithInvokeClosureNoinline(noinline s: (p: Int) -> Unit, noinline ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> s(p)}, { p -> this.ext(p)}) - subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subInline({p: Int -> s(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> s(p)}, { p -> this.ext(p)}) } //ext function @@ -28,8 +28,8 @@ inline fun Function1.inlineExt(ext: Int.(p: Int) -> Unit) { } inline fun Function1.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) { - subInline({p: Int -> this(p)}, { p -> this.ext(p)}) - subNoInline({p: Int -> this(p)}, { p -> this.ext(p)}) + subInline({p: Int -> this(p)}, { p -> this.ext(p)}) + subNoInline({p: Int -> this(p)}, { p -> this.ext(p)}) } inline fun subInline(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {} diff --git a/compiler/testData/diagnostics/tests/inline/property/invoke.fir.kt b/compiler/testData/diagnostics/tests/inline/property/invoke.fir.kt index f0f11d69994..6ab3469ec37 100644 --- a/compiler/testData/diagnostics/tests/inline/property/invoke.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/property/invoke.fir.kt @@ -13,8 +13,8 @@ inline var value: (p: Int) -> String inline var value2: Int.(p: Int) -> String get() = {"123" } set(ext: Int.(p: Int) -> String) { - 11.ext(11) - 11.ext(11) + 11.ext(11) + 11.ext(11) val p = ext } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inline/sam.fir.kt b/compiler/testData/diagnostics/tests/inline/sam.fir.kt index 31c5e88ccf4..2aa22055690 100644 --- a/compiler/testData/diagnostics/tests/inline/sam.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/sam.fir.kt @@ -19,8 +19,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { s.invoke(11) s invoke 11 - 11.ext(11) - 11 ext 11 + 11.ext(11) + 11 ext 11 s ext @@ -34,8 +34,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.( s.invoke(11) s invoke 11 - 11.ext(11) - 11 ext 11 + 11.ext(11) + 11 ext 11 s ext diff --git a/compiler/testData/diagnostics/tests/labels/kt4586.fir.kt b/compiler/testData/diagnostics/tests/labels/kt4586.fir.kt index 5ac3e300d34..80ff4c1115b 100644 --- a/compiler/testData/diagnostics/tests/labels/kt4586.fir.kt +++ b/compiler/testData/diagnostics/tests/labels/kt4586.fir.kt @@ -3,7 +3,7 @@ fun string(init: StringBuilder.() -> Unit): String{ val answer = StringBuilder() - answer.init() + answer.init() return answer.toString() } diff --git a/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.fir.kt b/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.fir.kt index cc43ae6d1cf..4355f8607a1 100644 --- a/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.fir.kt @@ -16,7 +16,7 @@ fun B.b() { fun test() { - fun without(f: T.() -> Unit): Unit = (null!!).f() + fun without(f: T.() -> Unit): Unit = (null!!).f() without() b@ { object : A { override fun foo() { diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/kt13330.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/kt13330.fir.kt index f811d50b9f8..13bc8707003 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/kt13330.fir.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/kt13330.fir.kt @@ -1,4 +1,4 @@ // !WITH_NEW_INFERENCE //KT-13330 AssertionError: Illegal resolved call to variable with invoke -fun foo(exec: (String.() -> Unit)?) = "".exec() // is test data tag here \ No newline at end of file +fun foo(exec: (String.() -> Unit)?) = "".exec() // is test data tag here \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/parameterNames/invokeInFunctionClass.fir.kt b/compiler/testData/diagnostics/tests/override/parameterNames/invokeInFunctionClass.fir.kt index 5fa63c79496..820b4bc9a52 100644 --- a/compiler/testData/diagnostics/tests/override/parameterNames/invokeInFunctionClass.fir.kt +++ b/compiler/testData/diagnostics/tests/override/parameterNames/invokeInFunctionClass.fir.kt @@ -21,7 +21,7 @@ fun test2(f: (String) -> Unit) { } fun test3(f: String.(String) -> Unit) { - "".f("") - "".f(p0 = "") - "".f(zzz = "") + "".f("") + "".f(p0 = "") + "".f(zzz = "") } diff --git a/compiler/testData/diagnostics/tests/regressions/Jet121.fir.kt b/compiler/testData/diagnostics/tests/regressions/Jet121.fir.kt index c3eddacc387..b062181aaa9 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet121.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet121.fir.kt @@ -10,5 +10,5 @@ return if (answer == 2) "OK" else "FAIL" } fun apply(arg:String, f : String.() -> Int) : Int { - return arg.f() + return arg.f() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt3731.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt3731.fir.kt index c68937faed5..de1728d6c84 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt3731.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt3731.fir.kt @@ -2,15 +2,15 @@ class A { fun foo() {} - fun bar(f: A.() -> Unit = {}) = f() + fun bar(f: A.() -> Unit = {}) = f() } class B { class D { init { A().bar { - this.foo() - foo() + this.foo() + foo() } } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt index 806772e9518..0e1d3c624ef 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt442.fir.kt @@ -21,7 +21,7 @@ fun generic_invoker(gen : (String) -> T) : T { } infix fun T.with(f : T.() -> Unit) { - f() + f() } fun main() { diff --git a/compiler/testData/diagnostics/tests/regressions/kt604.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt604.fir.kt index 43e81d89fde..3d2d8f8f2cd 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt604.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt604.fir.kt @@ -14,7 +14,7 @@ interface ChannelPipelineFactory{ class StandardPipelineFactory(val config: ChannelPipeline.()->Unit) : ChannelPipelineFactory { override fun getPipeline() : ChannelPipeline { val pipeline = DefaultChannelPipeline() - pipeline.config () + pipeline.config () return pipeline } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt9808.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt9808.fir.kt index 7d35fb2356f..1e8ce4f51a1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt9808.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt9808.fir.kt @@ -4,5 +4,5 @@ object O val foo: O.() -> Unit = null!! fun test() { - O.foo() + O.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.fir.kt b/compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.fir.kt index c4746cd8f7f..e3b2daf88eb 100644 --- a/compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.fir.kt @@ -2,6 +2,6 @@ object X class Y { fun f(op: X.() -> Unit) { - X.op() + X.op() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.fir.kt b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.fir.kt index f0bbf4e4823..d7f9a6bfdc3 100644 --- a/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.fir.kt @@ -2,7 +2,7 @@ fun foo(a: Any, f: ()->Int) = f() fun foo(a: Any, f: (Any)->Int) = f(a) -fun foo(i: Int, f: Int.()->Int) = i.f() +fun foo(i: Int, f: Int.()->Int) = i.f() fun test1() { foo(1) { -> diff --git a/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerOnTypealias.fir.kt b/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerOnTypealias.fir.kt index 763584c4628..b968e5bff83 100644 --- a/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerOnTypealias.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerOnTypealias.fir.kt @@ -12,17 +12,17 @@ typealias XBar = Bar typealias XXBar = XBar -fun Foo.foo(body: Foo.() -> Unit) = body() -fun Foo.xbar(body: XBar.() -> Unit) = Bar().body() -fun Foo.xxbar(body: XXBar.() -> Unit) = Bar().body() +fun Foo.foo(body: Foo.() -> Unit) = body() +fun Foo.xbar(body: XBar.() -> Unit) = Bar().body() +fun Foo.xxbar(body: XXBar.() -> Unit) = Bar().body() fun test() { Foo().foo { - xbar { - foo {} + xbar { + foo {} } - xxbar { - foo {} + xxbar { + foo {} } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerWithTypealiasRecursion.fir.kt b/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerWithTypealiasRecursion.fir.kt index 90e7fefe98d..1f56174c324 100644 --- a/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerWithTypealiasRecursion.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/dslMarker/dslMarkerWithTypealiasRecursion.fir.kt @@ -12,13 +12,13 @@ class Bar typealias YBar = ZBar typealias ZBar = YBar -fun Foo.foo(body: Foo.() -> Unit) = body() -fun Foo.zbar(body: ZBar.() -> Unit) = Bar().body() +fun Foo.foo(body: Foo.() -> Unit) = body() +fun Foo.zbar(body: ZBar.() -> Unit) = Bar().body() fun test() { Foo().foo { - zbar { - foo {} + zbar { + foo {} } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.fir.kt b/compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.fir.kt index d478dd2a6ed..902ce7e49e1 100644 --- a/compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/implicitReceiverProperty.fir.kt @@ -20,14 +20,14 @@ package test import a.A -fun T.with(f: T.() -> R) = f() +fun T.with(f: T.() -> R) = f() fun A.extFun1() = b.length // fun A.extFun2() = c.length // TODO fix KT-9953 -val x1 = A("").with { b.length } +val x1 = A("").with { b.length } // val x2 = A("").with { c.length } // TODO fix KT-9953 -val x3 = A.with { c.length } \ No newline at end of file +val x3 = A.with { c.length } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.fir.kt index 0956bf1e344..fcd8e258ada 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.fir.kt @@ -24,10 +24,10 @@ fun test(c: () -> String, e: Int.() -> String) { c() (c)() - 3.e() - 3.(e)() + 3.e() + 3.(e)() with(3) { - e() - (e)() + e() + (e)() } } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt index 3a5a8a49df6..0951bbf7fc1 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt @@ -15,8 +15,8 @@ fun test(a: A) { a.x() (a.x)() if (a.x != null) { - a.x() // todo - (a.x)() + a.x() // todo + (a.x)() } } } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtensionToExplicitReceiver.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtensionToExplicitReceiver.fir.kt index e4dda926053..a2c5d7721e1 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtensionToExplicitReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAsMemberExtensionToExplicitReceiver.fir.kt @@ -8,5 +8,5 @@ fun test(a: A, foo: Foo) { } fun test(a: Int, foo: Int.()->Unit) { - a.foo() + a.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt index 1bd97f6c098..77b688a36bf 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt @@ -55,21 +55,21 @@ fun test(a: A, b: B) { a.foo(b) with(a) { - b.foo() + b.foo() - b.(foo)() + b.(foo)() - (b.foo)() + (b.foo)() foo(b) (foo)(b) } with(b) { - a.foo() - a.(foo)() + a.foo() + a.(foo)() - (a.foo)() + (a.foo)() (a.foo)(this) a.foo(this) @@ -77,8 +77,8 @@ fun test(a: A, b: B) { with(a) { with(b) { - foo() - (foo)() + foo() + (foo)() } } } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/kt9805.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/kt9805.fir.kt index a0e0b9c1208..0b17b6e94b7 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/kt9805.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/kt9805.fir.kt @@ -6,11 +6,11 @@ class B fun test(a: A, b: B) { with(b) { - a.foo() // here must be error, because a is not extension receiver + a.foo() // here must be error, because a is not extension receiver a.foo(this) - (a.foo)() + (a.foo)() (a.foo)(this) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/valNamedInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/valNamedInvoke.fir.kt index 2c8cfdd48bf..6ac2e1c5cbc 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/valNamedInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/valNamedInvoke.fir.kt @@ -1,9 +1,9 @@ interface A fun foo(invoke: A.()->Unit, a: A) { - a.invoke() + a.invoke() } fun bar(invoke: Any.()->Any, a: Any) { - a.invoke() + a.invoke() } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/wrongInvokeExtension.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/wrongInvokeExtension.fir.kt index 66a1244efff..710bd3fb7ba 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/wrongInvokeExtension.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/wrongInvokeExtension.fir.kt @@ -12,7 +12,7 @@ fun test(a: A, b: B) { b.(a)() with(b) { - val y: Int = a() - (a)() + val y: Int = a() + (a)() } } diff --git a/compiler/testData/diagnostics/tests/resolve/priority/invokeExtensionVsOther.fir.kt b/compiler/testData/diagnostics/tests/resolve/priority/invokeExtensionVsOther.fir.kt index e92ef718eaf..aede07e6269 100644 --- a/compiler/testData/diagnostics/tests/resolve/priority/invokeExtensionVsOther.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/priority/invokeExtensionVsOther.fir.kt @@ -9,7 +9,7 @@ class B { fun test(foo: A.() -> Int) { with(A()) { - foo() checkType { _() } + foo() checkType { _() } with(B()) { foo() checkType { _() } this.foo() checkType { _() } diff --git a/compiler/testData/diagnostics/tests/safeCall.fir.kt b/compiler/testData/diagnostics/tests/safeCall.fir.kt index d613f2e5768..e63b91d60df 100644 --- a/compiler/testData/diagnostics/tests/safeCall.fir.kt +++ b/compiler/testData/diagnostics/tests/safeCall.fir.kt @@ -1,7 +1,7 @@ // !WITH_NEW_INFERENCE fun f(s: String, action: (String.() -> Unit)?) { - s.foo().bar().action() + s.foo().bar().action() } fun String.foo() = "" diff --git a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt index 9245393c58e..aa47ff958f1 100644 --- a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt +++ b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.fir.txt @@ -7,9 +7,10 @@ FILE fqName: fileName:/extFunInvokeAsFun.kt CALL 'public abstract fun invoke (p1: kotlin.Any?): kotlin.Unit [operator] 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 + FUN name:with2 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 with2 (receiver: kotlin.Any?, block: kotlin.Function1): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + RETURN type=kotlin.Nothing from='public final fun with2 (receiver: kotlin.Any?, block: kotlin.Function1): kotlin.Unit declared in ' + CALL 'public abstract fun invoke (p1: kotlin.Any?): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null + $this: GET_VAR 'block: kotlin.Function1 declared in .with2' type=kotlin.Function1 origin=null diff --git a/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt b/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt index f404661b7b4..947b3899491 100644 --- a/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt +++ b/compiler/testData/ir/irText/expressions/extFunSafeInvoke.fir.txt @@ -1,9 +1,10 @@ FILE fqName: fileName:/extFunSafeInvoke.kt - FUN name:test visibility:public modality:FINAL <> (receiver:kotlin.Any?, fn:kotlin.Function3) returnType:IrErrorType + FUN name:test visibility:public modality:FINAL <> (receiver:kotlin.Any?, fn:kotlin.Function3) returnType:kotlin.Unit? VALUE_PARAMETER name:receiver index:0 type:kotlin.Any? VALUE_PARAMETER name:fn index:1 type:kotlin.Function3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (receiver: kotlin.Any?, fn: kotlin.Function3): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - CONST Int type=kotlin.Int value=42 - CONST String type=kotlin.String value="Hello" + RETURN type=kotlin.Nothing from='public final fun test (receiver: kotlin.Any?, fn: kotlin.Function3): kotlin.Unit? declared in ' + CALL 'public abstract fun invoke (p1: kotlin.Any, p2: kotlin.Int, p3: kotlin.String): kotlin.Unit [operator] declared in kotlin.Function3' type=kotlin.Unit? origin=null + $this: GET_VAR 'fn: kotlin.Function3 declared in .test' type=kotlin.Function3 origin=null + p1: CONST Int type=kotlin.Int value=42 + p2: CONST String type=kotlin.String value="Hello" diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt index 753c82fa25e..f0cbf79fc4a 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.fir.txt @@ -13,11 +13,12 @@ FILE fqName: fileName:/variableAsFunctionCall.kt RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function0): kotlin.Unit declared in ' CALL 'public abstract fun invoke (): kotlin.Unit [operator] 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 + FUN name:test2 visibility:public modality:FINAL <> (f:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:f index:0 type:kotlin.Function1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1): kotlin.Unit declared in ' + CALL 'public abstract fun invoke (p1: kotlin.String): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null + $this: GET_VAR 'f: kotlin.Function1 declared in .test2' type=kotlin.Function1 origin=null FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.String declared in '