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:
@@ -470,6 +470,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<JetExpression, CallableMemberDescriptor> EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetExpression> CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetExpression> ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+4
-1
@@ -641,7 +641,10 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED,
|
||||
"''{0}'' is a member and an extension at the same time. References to such elements are not allowed", NAME);
|
||||
MAP.put(CALLABLE_REFERENCE_LHS_NOT_A_CLASS, "Left hand side of a callable reference cannot be a type parameter");
|
||||
MAP.put(CALLABLE_REFERENCE_LHS_NOT_A_CLASS, "Left-hand side of a callable reference cannot be a type parameter");
|
||||
MAP.put(CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS,
|
||||
"Left-hand side of a callable reference with a receiver parameter cannot be empty. " +
|
||||
"Please specify the type of the receiver before '::' explicitly");
|
||||
|
||||
MAP.put(CLASS_LITERAL_LHS_NOT_A_CLASS, "Only classes are allowed on the left hand side of a class literal");
|
||||
MAP.put(ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT, "kotlin.Array class literal requires a type argument, please specify one in angle brackets");
|
||||
|
||||
+5
-1
@@ -79,7 +79,6 @@ import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.DEPEN
|
||||
import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT;
|
||||
import static org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory.createDataFlowValue;
|
||||
import static org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||
import static org.jetbrains.kotlin.resolve.scopes.utils.UtilsPackage.asJetScope;
|
||||
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType;
|
||||
import static org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.createCallForSpecialConstruction;
|
||||
@@ -703,6 +702,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
if (descriptor == null) return null;
|
||||
|
||||
if (expression.getTypeReference() == null &&
|
||||
(descriptor.getDispatchReceiverParameter() != null || descriptor.getExtensionReceiverParameter() != null)) {
|
||||
context.trace.report(CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS.on(reference));
|
||||
}
|
||||
|
||||
return CallableReferencesPackage.createReflectionTypeForResolvedCallableReference(expression, descriptor, context, components.reflectionTypes);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package test
|
||||
class A(val z: Int) {
|
||||
fun calc() = z
|
||||
|
||||
fun test() = call(A(z), ::calc)
|
||||
fun test() = call(A(z), A::calc)
|
||||
}
|
||||
|
||||
inline fun call(p: A, s: A.() -> Int): Int {
|
||||
return p.s()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
fun foo(k: Int) = k
|
||||
|
||||
fun result() = (::foo)(this, 111)
|
||||
fun result() = (A::foo)(this, 111)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ class A {
|
||||
fun k(k: Int) = k
|
||||
}
|
||||
|
||||
fun A.foo() = (::o)(this) + (A::k)(this, 222)
|
||||
fun A.foo() = (A::o)(this) + (A::k)(this, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class A {
|
||||
fun result() = (::foo)(this, "OK")
|
||||
fun result() = (A::foo)(this, "OK")
|
||||
}
|
||||
|
||||
fun A.foo(x: String) = x
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@ class A {
|
||||
val k = 222
|
||||
}
|
||||
|
||||
fun result() = (A::Inner)(this).o + (::Inner)(this).k
|
||||
fun result() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@ class A {
|
||||
}
|
||||
}
|
||||
|
||||
fun A.foo() = (A::Inner)(this).o + (::Inner)(this).k
|
||||
fun A.foo() = (A::Inner)(this).o + (A::Inner)(this).k
|
||||
|
||||
fun box(): String {
|
||||
val result = A().foo()
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
private fun foo() = "OK"
|
||||
|
||||
fun bar() = (::foo)(this)
|
||||
fun bar() = (A::foo)(this)
|
||||
}
|
||||
|
||||
fun box() = A().bar()
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ interface T {
|
||||
|
||||
class B : T {
|
||||
inner class C {
|
||||
fun bar() = (::foo)(this@B)
|
||||
fun bar() = (T::foo)(this@B)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ class Test {
|
||||
public fun exec() {
|
||||
val t = object : Thread() {
|
||||
override fun run() {
|
||||
::iv.get(this@Test)
|
||||
::iv.set(this@Test, 2)
|
||||
Test::iv.get(this@Test)
|
||||
Test::iv.set(this@Test, 2)
|
||||
}
|
||||
}
|
||||
t.start()
|
||||
|
||||
+4
-3
@@ -1,3 +1,4 @@
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
|
||||
class K<in T : String> {
|
||||
@@ -6,10 +7,10 @@ class K<in T : String> {
|
||||
set(value) {}
|
||||
|
||||
fun run(): String {
|
||||
val p = ::t
|
||||
val p = K::class.memberProperties.single() as KMutableProperty1<K<String>, String>
|
||||
p.isAccessible = true
|
||||
p.set(this, "" as T)
|
||||
return p.get(this)
|
||||
p.set(this as K<String>, "")
|
||||
return p.get(this) as String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
val topLevelVal = 1
|
||||
fun topLevelFun() = 2
|
||||
|
||||
val A.extensionVal: Int get() = 3
|
||||
fun A.extensionFun(): Int = 4
|
||||
|
||||
class A {
|
||||
val memberVal = 5
|
||||
fun memberFun() = 6
|
||||
|
||||
val ok1 = ::topLevelVal
|
||||
val ok2 = ::topLevelFun
|
||||
|
||||
fun fail1() {
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>extensionVal<!>
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>extensionFun<!>
|
||||
}
|
||||
|
||||
fun fail2() {
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>memberVal<!>
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>memberFun<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
val ok1 = ::topLevelVal
|
||||
val ok2 = ::topLevelFun
|
||||
|
||||
fun A.fail1() {
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>extensionVal<!>
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>extensionFun<!>
|
||||
}
|
||||
|
||||
fun A.fail2() {
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>memberVal<!>
|
||||
::<!CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS!>memberFun<!>
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public val ok1: kotlin.reflect.KProperty0<kotlin.Int>
|
||||
public val ok2: kotlin.reflect.KFunction0<kotlin.Int>
|
||||
public val topLevelVal: kotlin.Int = 1
|
||||
public val A.extensionVal: kotlin.Int
|
||||
public fun topLevelFun(): kotlin.Int
|
||||
public fun A.extensionFun(): kotlin.Int
|
||||
public fun A.fail1(): kotlin.Unit
|
||||
public fun A.fail2(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final val memberVal: kotlin.Int = 5
|
||||
public final val ok1: kotlin.reflect.KProperty0<kotlin.Int>
|
||||
public final val ok2: kotlin.reflect.KFunction0<kotlin.Int>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun fail1(): kotlin.Unit
|
||||
public final fun fail2(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun memberFun(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
-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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ class A(var g: A) {
|
||||
val f: Int = 0
|
||||
|
||||
fun test() {
|
||||
val fRef: KProperty1<A, Int> = ::f
|
||||
val gRef: KMutableProperty1<A, A> = ::g
|
||||
val fRef: KProperty1<A, Int> = A::f
|
||||
val gRef: KMutableProperty1<A, A> = A::g
|
||||
}
|
||||
}
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !DIAGNOSTICS:-UNUSED_VARIABLE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
fun test() {
|
||||
val fooRef: KProperty1<A, String> = ::foo
|
||||
val barRef: KMutableProperty1<A, Int> = ::bar
|
||||
}
|
||||
}
|
||||
|
||||
val A.foo: String get() = ""
|
||||
var A.bar: Int
|
||||
get() = 42
|
||||
set(value) { }
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package
|
||||
|
||||
public var A.bar: kotlin.Int
|
||||
public val A.foo: kotlin.String
|
||||
|
||||
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 test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -6,7 +6,7 @@ class A(var g: A) {
|
||||
val f: Int = 0
|
||||
|
||||
fun test() {
|
||||
checkSubtype<KProperty1<A, Int>>(::f)
|
||||
checkSubtype<KMutableProperty1<A, A>>(::g)
|
||||
checkSubtype<KProperty1<A, Int>>(A::f)
|
||||
checkSubtype<KMutableProperty1<A, A>>(A::g)
|
||||
}
|
||||
}
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class A {
|
||||
val foo: Unit = Unit
|
||||
var bar: String = ""
|
||||
var self: A
|
||||
get() = this
|
||||
set(value) { }
|
||||
}
|
||||
|
||||
fun A.test() {
|
||||
val x = ::foo
|
||||
val y = ::bar
|
||||
val z = ::self
|
||||
|
||||
checkSubtype<KProperty1<A, Unit>>(x)
|
||||
checkSubtype<KMutableProperty1<A, String>>(y)
|
||||
checkSubtype<KMutableProperty1<A, A>>(z)
|
||||
|
||||
y.set(z.get(A()), x.get(A()).toString())
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package
|
||||
|
||||
public fun A.test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final var bar: kotlin.String
|
||||
public final val foo: kotlin.Unit
|
||||
public final var self: 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
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
>>> val foo = "REPL"
|
||||
>>> ::foo.name
|
||||
foo
|
||||
>>> ::
|
||||
... foo.name
|
||||
foo
|
||||
@@ -1539,6 +1539,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("emptyLhs.kt")
|
||||
public void testEmptyLhs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt7430_wrongClassOnLHS.kt")
|
||||
public void testKt7430_wrongClassOnLHS() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/kt7430_wrongClassOnLHS.kt");
|
||||
@@ -1631,24 +1637,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromClass.kt")
|
||||
public void testExtensionFromClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromExtension.kt")
|
||||
public void testExtensionFromExtension() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromExtensionInClass.kt")
|
||||
public void testExtensionFromExtensionInClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromTopLevel.kt")
|
||||
public void testExtensionFromTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt");
|
||||
@@ -1769,24 +1757,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromClass.kt")
|
||||
public void testMemberFromClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromExtension.kt")
|
||||
public void testMemberFromExtension() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromExtensionInClass.kt")
|
||||
public void testMemberFromExtensionInClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromTopLevel.kt")
|
||||
public void testMemberFromTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.kt");
|
||||
@@ -1892,12 +1862,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromClass.kt")
|
||||
public void testExtensionFromClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFromTopLevel.kt")
|
||||
public void testExtensionFromTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt");
|
||||
@@ -1946,12 +1910,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromExtension.kt")
|
||||
public void testMemberFromExtension() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("memberFromTopLevel.kt")
|
||||
public void testMemberFromTopLevel() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt");
|
||||
|
||||
@@ -257,21 +257,6 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/repl/reflection")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Reflection extends AbstractReplInterpreterTest {
|
||||
public void testAllFilesPresentInReflection() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/repl/reflection"), Pattern.compile("^(.+)\\.repl$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyReference.repl")
|
||||
public void testPropertyReference() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/repl/reflection/propertyReference.repl");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/repl/regressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ class A {
|
||||
inner class C
|
||||
|
||||
fun foo() {
|
||||
<selection>::B</selection>
|
||||
::C
|
||||
<selection>A::B</selection>
|
||||
A::C
|
||||
A::B
|
||||
A::C
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
::B
|
||||
A::B
|
||||
|
||||
A::B
|
||||
+2
-2
@@ -8,8 +8,8 @@ class A {
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<selection>::bar</selection>
|
||||
::baz
|
||||
<selection>A::bar</selection>
|
||||
A::baz
|
||||
A::bar
|
||||
A::baz
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
||||
::bar
|
||||
A::bar
|
||||
|
||||
A::bar
|
||||
+1
-1
@@ -4,7 +4,7 @@ package foo
|
||||
class A {
|
||||
fun bar(k: Int) = k
|
||||
|
||||
fun result() = (::bar)(this, 111)
|
||||
fun result() = (A::bar)(this, 111)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ class A {
|
||||
fun k(k: Int) = k
|
||||
}
|
||||
|
||||
fun A.bar() = (::o)(this) + (A::k)(this, 222)
|
||||
fun A.bar() = (A::o)(this) + (A::k)(this, 222)
|
||||
|
||||
fun box(): String {
|
||||
val result = A().bar()
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
fun result() = (::bar)(this, "OK")
|
||||
fun result() = (A::bar)(this, "OK")
|
||||
}
|
||||
|
||||
fun A.bar(x: String) = x
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ package foo
|
||||
fun A.f(s: String) = value + s
|
||||
|
||||
class A(val value: String) {
|
||||
fun bar(s: String) = (::f)(this, s)
|
||||
fun bar(s: String) = (A::f)(this, s)
|
||||
}
|
||||
|
||||
fun A.baz(s: String) = (::f)(this, s)
|
||||
fun A.baz(s: String) = (A::f)(this, s)
|
||||
|
||||
fun box(): String {
|
||||
val a = A("aaa")
|
||||
|
||||
Reference in New Issue
Block a user