Allowed call value with extension function type as simple function type.
This commit is contained in:
+1
-1
@@ -120,7 +120,7 @@ private object FunctionCollector : CallableDescriptorCollector<FunctionDescripto
|
||||
// (because declarations beat synthesized members)
|
||||
val (candidatesForReplacement, irrelevantInvokes) =
|
||||
members.partition { it is FunctionInvokeDescriptor && it.valueParameters.isNotEmpty() }
|
||||
return createSynthesizedInvokes(candidatesForReplacement) + irrelevantInvokes + constructors
|
||||
return createSynthesizedInvokes(candidatesForReplacement) + candidatesForReplacement + irrelevantInvokes + constructors
|
||||
}
|
||||
|
||||
return members + constructors
|
||||
|
||||
@@ -73,7 +73,7 @@ fun main1() {
|
||||
|
||||
fun test() {
|
||||
{x : Int -> 1}(<!NO_VALUE_FOR_PARAMETER!>)<!>;
|
||||
<!MISSING_RECEIVER!>(fun Int.() = 1)<!>()
|
||||
(fun Int.() = 1)(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
<!TYPE_MISMATCH!>"sd"<!>.(fun Int.() = 1)()
|
||||
val i : Int? = null
|
||||
i<!UNSAFE_CALL!>.<!>(fun Int.() = 1)();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Manager {
|
||||
|
||||
class Task(val callback: Manager.() -> Unit) : Runnable {
|
||||
override public fun run() {
|
||||
<!MISSING_RECEIVER!>callback<!>() // Manager is not accessible here, but no error is shown
|
||||
callback(<!NO_VALUE_FOR_PARAMETER!>)<!> // Manager is not accessible here, but no error is shown
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
fun test1(f: String.() -> Unit) {
|
||||
<!MISSING_RECEIVER!>(f)<!>()
|
||||
(f)(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
|
||||
<!MISSING_RECEIVER!>f<!>()
|
||||
f(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
fun test2(f: (Int) -> Int) {
|
||||
|
||||
+22
@@ -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())
|
||||
|
||||
<!UNREACHABLE_CODE!>return<!> null!!
|
||||
}
|
||||
+19
@@ -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
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user