diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index d3b0c16b258..3c8fd37c2ca 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -470,6 +470,7 @@ public interface Errors { DiagnosticFactory1 EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 CALLABLE_REFERENCE_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 129507b4273..04689446d3c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -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"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 0415bd2e13f..5367a04fd14 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -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); } diff --git a/compiler/testData/codegen/boxInline/callableReference/classLevel2.2.kt b/compiler/testData/codegen/boxInline/callableReference/classLevel2.2.kt index 8da891496ae..56136110b36 100644 --- a/compiler/testData/codegen/boxInline/callableReference/classLevel2.2.kt +++ b/compiler/testData/codegen/boxInline/callableReference/classLevel2.2.kt @@ -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() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt index 7f5fd04017f..3ed816ee504 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt @@ -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 { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt index 607fa3700f5..9619233c943 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt @@ -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() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt index f5dabed6746..0248c2f9f2c 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt @@ -1,5 +1,5 @@ class A { - fun result() = (::foo)(this, "OK") + fun result() = (A::foo)(this, "OK") } fun A.foo(x: String) = x diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt index 53b31fa77d0..31bb102ee62 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt @@ -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 { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt index aad8cb2a97a..bcde4b24cae 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt @@ -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() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt index c796995fc67..f99ac7e3ad6 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt @@ -1,7 +1,7 @@ class A { private fun foo() = "OK" - fun bar() = (::foo)(this) + fun bar() = (A::foo)(this) } fun box() = A().bar() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt index 51923a24746..9171f0b094b 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt @@ -4,7 +4,7 @@ interface T { class B : T { inner class C { - fun bar() = (::foo)(this@B) + fun bar() = (T::foo)(this@B) } } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt index 3bfa39df049..0b5ad7a54ac 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt @@ -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() diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateToThisAccessors.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateToThisAccessors.kt index 996eacc4a41..bbbacc99338 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateToThisAccessors.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateToThisAccessors.kt @@ -1,3 +1,4 @@ +import kotlin.reflect.* import kotlin.reflect.jvm.* class K { @@ -6,10 +7,10 @@ class K { set(value) {} fun run(): String { - val p = ::t + val p = K::class.memberProperties.single() as KMutableProperty1, String> p.isAccessible = true - p.set(this, "" as T) - return p.get(this) + p.set(this as K, "") + return p.get(this) as String } } diff --git a/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt new file mode 100644 index 00000000000..d814b08aceb --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt @@ -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() { + ::extensionVal + ::extensionFun + } + + fun fail2() { + ::memberVal + ::memberFun + } +} + + + +val ok1 = ::topLevelVal +val ok2 = ::topLevelFun + +fun A.fail1() { + ::extensionVal + ::extensionFun +} + +fun A.fail2() { + ::memberVal + ::memberFun +} diff --git a/compiler/testData/diagnostics/tests/callableReference/emptyLhs.txt b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.txt new file mode 100644 index 00000000000..4d1fabe6b45 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.txt @@ -0,0 +1,23 @@ +package + +public val ok1: kotlin.reflect.KProperty0 +public val ok2: kotlin.reflect.KFunction0 +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 + public final val ok2: kotlin.reflect.KFunction0 + 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 +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt deleted file mode 100644 index 273919e3ed7..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !CHECK_TYPE - -import kotlin.reflect.* - -class A { - fun main() { - val x = ::foo - val y = ::bar - val z = ::baz - - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) - } -} - -fun A.foo() {} -fun A.bar(x: Int) {} -fun A.baz() = "OK" diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.txt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.txt deleted file mode 100644 index 9f38ba070a3..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt deleted file mode 100644 index 7c7a7ea2b2b..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !CHECK_TYPE - -import kotlin.reflect.* - -class A - -fun A.main() { - val x = ::foo - val y = ::bar - val z = ::baz - - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) -} - -fun A.foo() {} -fun A.bar(x: Int) {} -fun A.baz() = "OK" diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.txt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.txt deleted file mode 100644 index 20ce2aa6e09..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt deleted file mode 100644 index b0b4893a4c7..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt +++ /dev/null @@ -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>(x) - checkSubtype>(y) - checkSubtype>(z) - } -} - -fun A.foo() {} -fun A.bar(x: Int) {} -fun A.baz() = "OK" diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.txt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.txt deleted file mode 100644 index 0d1e129326e..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionInClassDisallowed.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionInClassDisallowed.kt index 03ce8655046..2c92931d6af 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionInClassDisallowed.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionInClassDisallowed.kt @@ -4,8 +4,8 @@ class A { fun A.extA(x: String) = x fun main() { - ::extInt - ::extA + Int::extInt + A::extA } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt index 887e8f1c567..6fa5e6c14eb 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt @@ -6,10 +6,9 @@ class A { inner class Inner fun main() { - val x = ::Inner + ::Inner val y = A::Inner - checkSubtype>(x) checkSubtype>(y) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt index b23bcdf370d..74c6dbbd2b5 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt @@ -7,10 +7,9 @@ class A { } fun A.main() { - val x = ::Inner + ::Inner val y = A::Inner - checkSubtype>(x) checkSubtype>(y) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt deleted file mode 100644 index 908e073857b..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !CHECK_TYPE - -import kotlin.reflect.* - -class A { - fun foo() {} - fun bar(x: Int) {} - fun baz() = "OK" - - fun main() { - val x = ::foo - val y = ::bar - val z = ::baz - - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) - } -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.txt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.txt deleted file mode 100644 index 5f031140fd6..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt deleted file mode 100644 index 045edb34120..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !CHECK_TYPE - -import kotlin.reflect.* - -class A { - fun foo() {} - fun bar(x: Int) {} - fun baz() = "OK" -} - -fun A.main() { - val x = ::foo - val y = ::bar - val z = ::baz - - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.txt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.txt deleted file mode 100644 index fc26cae3470..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt deleted file mode 100644 index 5789a95e8af..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt +++ /dev/null @@ -1,21 +0,0 @@ -// !CHECK_TYPE - -import kotlin.reflect.* - -class A { - fun foo() {} - fun bar(x: Int) {} - fun baz() = "OK" -} - -class B { - fun A.main() { - val x = ::foo - val y = ::bar - val z = ::baz - - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) - } -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.txt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.txt deleted file mode 100644 index fdc8dc7434b..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt index 6424f6c7f19..7e77faf1255 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt @@ -8,7 +8,7 @@ class A { fun foo() {} fun main() { - val x = ::foo + val x = ::foo checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt index b5d3570a170..8630be83473 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt @@ -6,7 +6,7 @@ class A(var g: A) { val f: Int = 0 fun test() { - val fRef: KProperty1 = ::f - val gRef: KMutableProperty1 = ::g + val fRef: KProperty1 = A::f + val gRef: KMutableProperty1 = A::g } } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt deleted file mode 100644 index e28b2c4c6d2..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt +++ /dev/null @@ -1,15 +0,0 @@ -// !DIAGNOSTICS:-UNUSED_VARIABLE - -import kotlin.reflect.* - -class A { - fun test() { - val fooRef: KProperty1 = ::foo - val barRef: KMutableProperty1 = ::bar - } -} - -val A.foo: String get() = "" -var A.bar: Int - get() = 42 - set(value) { } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.txt b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.txt deleted file mode 100644 index 57fe07cc0ef..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt b/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt index 26295d99f72..0be4a663de9 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt @@ -6,7 +6,7 @@ class A(var g: A) { val f: Int = 0 fun test() { - checkSubtype>(::f) - checkSubtype>(::g) + checkSubtype>(A::f) + checkSubtype>(A::g) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt deleted file mode 100644 index 32958ec26ab..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt +++ /dev/null @@ -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>(x) - checkSubtype>(y) - checkSubtype>(z) - - y.set(z.get(A()), x.get(A()).toString()) -} diff --git a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.txt b/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.txt deleted file mode 100644 index 06bc004a5ad..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.txt +++ /dev/null @@ -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 -} diff --git a/compiler/testData/repl/reflection/propertyReference.repl b/compiler/testData/repl/reflection/propertyReference.repl deleted file mode 100644 index 9f3e71fa9f3..00000000000 --- a/compiler/testData/repl/reflection/propertyReference.repl +++ /dev/null @@ -1,6 +0,0 @@ ->>> val foo = "REPL" ->>> ::foo.name -foo ->>> :: -... foo.name -foo diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index e77df846704..6b2e27c08cf 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -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"); diff --git a/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java index 88e6b383b61..3f6169d0c48 100644 --- a/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/repl/ReplInterpreterTestGenerated.java @@ -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) diff --git a/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt b/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt index a6c2cac0326..9b57988050f 100644 --- a/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt +++ b/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt @@ -4,8 +4,8 @@ class A { inner class C fun foo() { - ::B - ::C + A::B + A::C A::B A::C } diff --git a/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt.match b/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt.match index 6197af02bf6..bdff5957546 100644 --- a/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt.match +++ b/idea/testData/unifier/equivalence/expressions/callableReferences/classRefRuntime.kt.match @@ -1,3 +1,3 @@ -::B +A::B A::B \ No newline at end of file diff --git a/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt b/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt index 2091bb57eee..56016db9695 100644 --- a/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt +++ b/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt @@ -8,8 +8,8 @@ class A { } fun foo() { - ::bar - ::baz + A::bar + A::baz A::bar A::baz } diff --git a/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt.match b/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt.match index ebeaac63ccc..3c3d756dfd1 100644 --- a/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt.match +++ b/idea/testData/unifier/equivalence/expressions/callableReferences/functionRefRuntime.kt.match @@ -1,3 +1,3 @@ -::bar +A::bar A::bar \ No newline at end of file diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt index 6ccd9aba4f6..8c72feccd3a 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt @@ -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 { diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt index 4355161af61..6f5e67db6ef 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt @@ -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() diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt index 80806ebd149..73e780dd1e2 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt @@ -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 diff --git a/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt b/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt index 5c32ed9f60b..0dfebf02459 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt @@ -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")