Forbid callable references to members and extensions with empty LHS
This syntax is reserved to be likely used in the future as a shorthand for "this::foo" where the resulting expression doesn't take the receiver as a parameter but has "this" already bound to it
This commit is contained in:
-19
@@ -1,19 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package
|
||||
|
||||
public fun A.bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun A.baz(): kotlin.String
|
||||
public fun A.foo(): 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 final fun main(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package
|
||||
|
||||
public fun A.bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun A.baz(): kotlin.String
|
||||
public fun A.foo(): kotlin.Unit
|
||||
public fun A.main(): 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
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class B
|
||||
|
||||
class A {
|
||||
fun B.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun A.bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun A.baz() = "OK"
|
||||
Vendored
-20
@@ -1,20 +0,0 @@
|
||||
package
|
||||
|
||||
public fun A.bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public fun A.baz(): kotlin.String
|
||||
public fun A.foo(): 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 fun B.main(): kotlin.Unit
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
Vendored
+2
-2
@@ -4,8 +4,8 @@ class A {
|
||||
fun A.extA(x: String) = x
|
||||
|
||||
fun main() {
|
||||
::<!MISSING_RECEIVER, EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extInt<!>
|
||||
::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extA<!>
|
||||
Int::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extInt<!>
|
||||
A::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>extA<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-2
@@ -6,10 +6,9 @@ class A {
|
||||
inner class Inner
|
||||
|
||||
fun main() {
|
||||
val x = ::Inner
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(x)
|
||||
checkSubtype<KFunction1<A, Inner>>(y)
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-2
@@ -7,10 +7,9 @@ class A {
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
val x = ::Inner
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>Inner<!>
|
||||
val y = A::Inner
|
||||
|
||||
checkSubtype<KFunction1<A, A.Inner>>(x)
|
||||
checkSubtype<KFunction1<A, A.Inner>>(y)
|
||||
}
|
||||
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public final fun baz(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun main(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package
|
||||
|
||||
public fun A.main(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public final fun baz(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
}
|
||||
|
||||
class B {
|
||||
fun A.main() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::baz
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
checkSubtype<KFunction2<A, Int, Unit>>(y)
|
||||
checkSubtype<KFunction1<A, String>>(z)
|
||||
}
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final fun bar(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
public final fun baz(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
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 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 fun A.main(): kotlin.Unit
|
||||
}
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ class A {
|
||||
fun foo() {}
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
val x = ::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>foo<!>
|
||||
|
||||
checkSubtype<KFunction1<A, Unit>>(x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user