diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index 2bb90ed30c6..6f1611f699f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -120,7 +120,7 @@ private object FunctionCollector : CallableDescriptorCollector 1}(); - (fun Int.() = 1)() + (fun Int.() = 1)() "sd".(fun Int.() = 1)() val i : Int? = null i.(fun Int.() = 1)(); diff --git a/compiler/testData/diagnostics/tests/regressions/kt5362.kt b/compiler/testData/diagnostics/tests/regressions/kt5362.kt index 3c0e5c85457..01590fb2bfe 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt5362.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt5362.kt @@ -24,7 +24,7 @@ public class Manager { class Task(val callback: Manager.() -> Unit) : Runnable { override public fun run() { - callback() // Manager is not accessible here, but no error is shown + callback() // Manager is not accessible here, but no error is shown } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt index 44a8ddc8f32..93075ccb707 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.kt @@ -1,7 +1,7 @@ fun test1(f: String.() -> Unit) { - (f)() + (f)() - f() + f() } fun test2(f: (Int) -> Int) { diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.kt b/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.kt new file mode 100644 index 00000000000..bc6110d5d4e --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +class A + +fun test(foo: A.() -> Int, a: A) { + val b: Int = foo(a) + val c: Int = (foo)(a) +} + +class B { + val foo: A.() -> Int = null!! + + init { + val b: Int = foo(A()) + } +} + +fun foo(): A.() -> Int { + val b: Int = foo()(A()) + val c: Int = (foo())(A()) + + return null!! +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.txt b/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.txt new file mode 100644 index 00000000000..5b9110b45ea --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.txt @@ -0,0 +1,19 @@ +package + +public fun foo(): A.() -> kotlin.Int +public fun test(/*0*/ foo: A.() -> kotlin.Int, /*1*/ a: A): kotlin.Unit + +public final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class B { + public constructor B() + public final val foo: A.() -> kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 5d4cb816692..0f42ad3cdfe 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -13013,6 +13013,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("extensionValueAsNonExtension.kt") + public void testExtensionValueAsNonExtension() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/extensionValueAsNonExtension.kt"); + doTest(fileName); + } + @TestMetadata("implicitInvoke.kt") public void testImplicitInvoke() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.kt");