diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt new file mode 100644 index 00000000000..0b57fd2fadb --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt @@ -0,0 +1,9 @@ +internal class Methodprivate constructor(val name: String, val signature: T) { + companion object { + operator fun invoke(name: String): Method = TODO() + } +} + +fun foo() { + Method("asd") +} diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.txt new file mode 100644 index 00000000000..f5fa0e2c996 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.txt @@ -0,0 +1,27 @@ +FILE: companionInvoke.kt + internal final class Method : R|kotlin/Any| { + private constructor(name: R|kotlin/String|, signature: R|T|): R|Method| { + super() + } + + public[internal] final val name: R|kotlin/String| = R|/name| + public get(): R|kotlin/String| + + public[internal] final val signature: R|T| = R|/signature| + public get(): R|T| + + public[internal] final companion object Companion : R|kotlin/Any| { + private constructor(): R|Method.Companion| { + super() + } + + public[internal] final operator fun invoke(name: R|kotlin/String|): R|Method| { + ^invoke R|kotlin/TODO|() + } + + } + + } + public final fun foo(): R|kotlin/Unit| { + Q|Method|.R|/Method.Companion.invoke|(String(asd)) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt new file mode 100644 index 00000000000..7ce2970b9a3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt @@ -0,0 +1,7 @@ +object Bar { + operator fun invoke(x: String) {} +} + +fun foo() { + Bar("asd") +} diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.txt new file mode 100644 index 00000000000..fa000b52d25 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.txt @@ -0,0 +1,13 @@ +FILE: objectInvoke.kt + public final object Bar : R|kotlin/Any| { + private constructor(): R|Bar| { + super() + } + + public final operator fun invoke(x: R|kotlin/String|): R|kotlin/Unit| { + } + + } + public final fun foo(): R|kotlin/Unit| { + Q|Bar|.R|/Bar.invoke|(String(asd)) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt b/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt index 1ee59420868..96e824a598c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.kt @@ -8,13 +8,13 @@ fun case1(a: A?) { Case1.invoke(it) //resolved to private constructor - Case1(it) //resolved to private constructor + Case1(it) //resolved to private constructor - Case1(A()) //resolved to private constructor + Case1(A()) //resolved to private constructor } - Case1(A()) //resolved to private constructor - Case1(a = A()) //resolved to private constructor + Case1(A()) //resolved to private constructor + Case1(a = A()) //resolved to private constructor } class Case1 private constructor(val a: String) { @@ -25,8 +25,8 @@ class Case1 private constructor(val a: String) { // TESTCASE NUMBER: 2 fun case2(a: A){ - Case2(a) - Case2(a = a) + Case2(a) + Case2(a = a) } class Case2 { @@ -44,4 +44,4 @@ class Case3 { companion object { operator fun invoke(parameterA: A) = "" //(2) } -} \ No newline at end of file +} diff --git a/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.txt b/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.txt index 2a874b5cb8b..961e4d7401a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.txt +++ b/compiler/fir/analysis-tests/testData/resolve/companionObjectCall.txt @@ -6,14 +6,14 @@ FILE: companionObjectCall.kt } public final fun case1(a: R|A?|): R|kotlin/Unit| { - lval test: R|kotlin/Nothing?| = R|/a|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Nothing| { + lval test: R|kotlin/String?| = R|/a|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/String| { Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) - #(R|/it|) - ^ #(R|/A.A|()) + Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) + ^ Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) } ) - #(R|/A.A|()) - #(a = R|/A.A|()) + Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) + Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|()) } public final class Case1 : R|kotlin/Any| { private constructor(a: R|kotlin/String|): R|Case1| { @@ -36,8 +36,8 @@ FILE: companionObjectCall.kt } public final fun case2(a: R|A|): R|kotlin/Unit| { - #(R|/a|) - #(a = R|/a|) + Q|Case2|.R|/Case2.Companion.invoke|(R|/a|) + Q|Case2|.R|/Case2.Companion.invoke|(a = R|/a|) } public final class Case2 : R|kotlin/Any| { public constructor(): R|Case2| { @@ -57,8 +57,8 @@ FILE: companionObjectCall.kt } public final fun case3(a: R|A|): R|kotlin/Unit| { - Q|Case3|.R|/Case3.Companion|.R|/Case3.Companion.invoke|(R|/a|) - Q|Case3|.R|/Case3.Companion|.R|/Case3.Companion.invoke|(parameterA = R|/a|) + Q|Case3.Companion|.R|/Case3.Companion.invoke|(R|/a|) + Q|Case3.Companion|.R|/Case3.Companion.invoke|(parameterA = R|/a|) } public final class Case3 : R|kotlin/Any| { public constructor(): R|Case3| { diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index a9a530a794f..e07e529c59f 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -567,6 +567,29 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/callResolution") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CallResolution extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCallResolution() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/callResolution"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("companionInvoke.kt") + public void testCompanionInvoke() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt"); + } + + @TestMetadata("objectInvoke.kt") + public void testObjectInvoke() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/cfg") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 6d232619983..6422f2fc31b 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -567,6 +567,29 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/callResolution") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CallResolution extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCallResolution() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/callResolution"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("companionInvoke.kt") + public void testCompanionInvoke() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/companionInvoke.kt"); + } + + @TestMetadata("objectInvoke.kt") + public void testObjectInvoke() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/objectInvoke.kt"); + } + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/cfg") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index bfe1a4c738e..6db186bd33b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionStub -import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedReifiedParameterReference import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirReference @@ -210,22 +209,7 @@ class FirCallResolver( when { referencedSymbol is FirClassLikeSymbol<*> -> { - val classId = referencedSymbol.classId - return buildResolvedQualifier { - source = nameReference.source - packageFqName = classId.packageFqName - relativeClassFqName = classId.relativeClassName - safe = false - typeArguments.addAll(qualifiedAccess.typeArguments) - symbol = referencedSymbol - }.apply { - resultType = if (classId.isLocal) { - typeForQualifierByDeclaration(referencedSymbol.fir, resultType, session) - ?: session.builtinTypes.unitType - } else { - typeForQualifier(this) - } - } + return buildResolvedQualifierForClass(referencedSymbol, nameReference.source, qualifiedAccess.typeArguments) } referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> { return buildResolvedReifiedParameterReference { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index bd378510b59..13bfd439970 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.expressions.FirResolvable import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.builder.FirResolvedReifiedParameterReferenceBuilder import org.jetbrains.kotlin.fir.expressions.builder.buildExpressionWithSmartcast +import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference @@ -245,6 +246,30 @@ fun createKPropertyType( return ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(classId), arguments.toTypedArray(), isNullable = false) } +fun BodyResolveComponents.buildResolvedQualifierForClass( + regularClass: FirClassLikeSymbol<*>, + sourceElement: FirSourceElement? = null, + // TODO: Clarify if we actually need type arguments for qualifier? + typeArgumentsForQualifier: List = emptyList() +): FirResolvedQualifier { + val classId = regularClass.classId + return buildResolvedQualifier { + source = sourceElement + packageFqName = classId.packageFqName + relativeClassFqName = classId.relativeClassName + safe = false + typeArguments.addAll(typeArgumentsForQualifier) + symbol = regularClass + }.apply { + resultType = if (classId.isLocal) { + typeForQualifierByDeclaration(regularClass.fir, resultType, session) + ?: session.builtinTypes.unitType + } else { + typeForQualifier(this) + } + } +} + fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifier): FirTypeRef { val classSymbol = resolvedQualifier.symbol val resultType = resolvedQualifier.resultType diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolverSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolverSession.kt index 36d471f880f..4d2ebccf5f7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolverSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolverSession.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.builder.FirQualifiedAccessExpressionBuilder import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents -import org.jetbrains.kotlin.fir.resolve.constructType +import org.jetbrains.kotlin.fir.resolve.buildResolvedQualifierForClass import org.jetbrains.kotlin.fir.resolve.scope import org.jetbrains.kotlin.fir.resolve.transformQualifiedAccessUsingSmartcastInfo import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirStaticScope import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST @@ -688,25 +687,30 @@ private fun BodyResolveComponents.createExplicitReceiverForInvoke( invokeBuiltinExtensionMode: Boolean, extensionReceiverExpression: FirExpression ): FirExpression { - val (name, typeRef) = when (val symbol = candidate.symbol) { - is FirCallableSymbol<*> -> { - symbol.callableId.callableName to returnTypeCalculator.tryCalculateReturnType(symbol.firUnsafe()) - } - is FirRegularClassSymbol -> { - symbol.classId.shortClassName to buildResolvedTypeRef { - type = symbol.constructType(emptyArray(), isNullable = false) - } - } + return when (val symbol = candidate.symbol) { + is FirCallableSymbol<*> -> createExplicitReceiverForInvokeByCallable( + candidate, info, invokeBuiltinExtensionMode, extensionReceiverExpression, symbol + ) + is FirRegularClassSymbol -> buildResolvedQualifierForClass(symbol, sourceElement = null) else -> throw AssertionError() } +} + +private fun BodyResolveComponents.createExplicitReceiverForInvokeByCallable( + candidate: Candidate, + info: CallInfo, + invokeBuiltinExtensionMode: Boolean, + extensionReceiverExpression: FirExpression, + symbol: FirCallableSymbol<*> +): FirExpression { return FirQualifiedAccessExpressionBuilder().apply { calleeReference = FirNamedReferenceWithCandidate( null, - name, + symbol.callableId.callableName, candidate ) dispatchReceiver = candidate.dispatchReceiverExpression() - this.typeRef = typeRef + this.typeRef = returnTypeCalculator.tryCalculateReturnType(symbol.firUnsafe()) if (!invokeBuiltinExtensionMode) { extensionReceiver = extensionReceiverExpression diff --git a/compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt b/compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt index 0efc121da4a..66e41dc7b87 100644 --- a/compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt +++ b/compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // !LANGUAGE: +NewInference // WITH_RUNTIME @@ -35,4 +34,4 @@ fun box(): String { if (!test2()) return "fail2" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject1.kt index 98dbabe1af4..5f7fbce55f9 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { companion object { operator fun invoke(i: Int) = i diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject2.kt index faf5424906c..b808ed09f6a 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObject2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface B operator fun B.invoke(i: Int) = i diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass1.kt index 710c1d5f5e8..dcc924a9ba8 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { class Nested { companion object { diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass2.kt index 0bd795b5722..85b73084d1a 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnClassObjectOfNestedClass2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import A.Nested class A { diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject1.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject1.kt index f113c4a14c4..4bcc1429f3d 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject1.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject1.kt @@ -1,6 +1,5 @@ -// IGNORE_BACKEND_FIR: JVM_IR object A operator fun A.invoke(i: Int) = i -fun box() = if (A(42) == 42) "OK" else "fail" \ No newline at end of file +fun box() = if (A(42) == 42) "OK" else "fail" diff --git a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject2.kt b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject2.kt index 5ca7213ef28..ae213311420 100644 --- a/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject2.kt +++ b/compiler/testData/codegen/box/diagnostics/functions/invoke/onObjects/invokeOnObject2.kt @@ -1,6 +1,5 @@ -// IGNORE_BACKEND_FIR: JVM_IR object A { operator fun invoke(i: Int) = i } -fun box() = if (A(42) == 42) "OK" else "fail" \ No newline at end of file +fun box() = if (A(42) == 42) "OK" else "fail" diff --git a/compiler/testData/codegen/box/functions/invoke/implicitInvokeInCompanionObjectWithFunctionalArgument.kt b/compiler/testData/codegen/box/functions/invoke/implicitInvokeInCompanionObjectWithFunctionalArgument.kt index 700b34f2735..4ad1094c9c6 100644 --- a/compiler/testData/codegen/box/functions/invoke/implicitInvokeInCompanionObjectWithFunctionalArgument.kt +++ b/compiler/testData/codegen/box/functions/invoke/implicitInvokeInCompanionObjectWithFunctionalArgument.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class TestClass { companion object { inline operator fun invoke(task: () -> T) = task() @@ -12,4 +11,4 @@ fun box(): String { val ok = "OK" val x = TestClass { return ok } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/callableReference/kt32267.fir.kt b/compiler/testData/diagnostics/tests/callableReference/kt32267.fir.kt deleted file mode 100644 index 37af30f8af0..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/kt32267.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -// SKIP_TXT -// !DIAGNOSTICS: -UNUSED_PARAMETER -// !LANGUAGE: +NewInference - -fun main() { - Configuration().commands { - Command1 { someService::execute } // Overload resolution ambiguity. All these functions match. - Command2 { someService::execute } // Overload resolution ambiguity. All these functions match. - Command1 { { someService.execute(it) } } // fine - Command2 { { someService.execute(it) } } // fine - } -} -interface Command -interface CommandFactory -class Command1 : Command { - companion object : CommandFactory -} -class Command2 : Command { - companion object : CommandFactory -} -class Configuration { - val commands = Commands() - inline fun commands(configure: Commands.() -> Unit) { - commands.configure() - } - class Commands { - operator fun CommandFactory.invoke( - handler: Transaction.() -> ((command: TCommand) -> Unit) - ) { - } - } -} -interface Transaction { - val someService: SomeService -} -interface SomeService { - fun execute(command: Command1) - fun execute(command: Command2) -} diff --git a/compiler/testData/diagnostics/tests/callableReference/kt32267.kt b/compiler/testData/diagnostics/tests/callableReference/kt32267.kt index a885e6375cf..aad43e06536 100644 --- a/compiler/testData/diagnostics/tests/callableReference/kt32267.kt +++ b/compiler/testData/diagnostics/tests/callableReference/kt32267.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_TXT // !DIAGNOSTICS: -UNUSED_PARAMETER // !LANGUAGE: +NewInference diff --git a/compiler/testData/diagnostics/tests/inference/implicitInvokeInCompanionObjectWithFunctionalArgument.fir.kt b/compiler/testData/diagnostics/tests/inference/implicitInvokeInCompanionObjectWithFunctionalArgument.fir.kt index e1b9948e568..6335fc1b530 100644 --- a/compiler/testData/diagnostics/tests/inference/implicitInvokeInCompanionObjectWithFunctionalArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/implicitInvokeInCompanionObjectWithFunctionalArgument.fir.kt @@ -9,9 +9,9 @@ class TestClass { } fun test(s: String): String { - val a = TestClass { "K" } - a checkType { _() } + val a = TestClass { "K" } + a checkType { _() } - val b = TestClass { return s } - b checkType { _() } -} \ No newline at end of file + val b = TestClass { return s } + b checkType { _() } +} diff --git a/compiler/testData/diagnostics/tests/resolve/constructorVsCompanion.fir.kt b/compiler/testData/diagnostics/tests/resolve/constructorVsCompanion.fir.kt index 1f446ed239b..6e45eab1c78 100644 --- a/compiler/testData/diagnostics/tests/resolve/constructorVsCompanion.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/constructorVsCompanion.fir.kt @@ -20,4 +20,4 @@ val a = A val b = B val c = C val d = D -val e = E(42) \ No newline at end of file +val e = E(42) diff --git a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt index af9e1fbf505..3187ad27fab 100644 --- a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt @@ -83,7 +83,7 @@ FILE fqName: fileName:/objectAsCallable.kt FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Int visibility:private [final,static] EXPRESSION_BODY CALL 'public final fun invoke (i: kotlin.Int): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null - $receiver: ERROR_CALL 'Unresolved reference: R|/A|' type=IrErrorType + $receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A i: CONST Int type=kotlin.Int value=42 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val]