diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 82b4cc8c60b..d63e745a3ef 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -501,6 +501,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 CALLABLE_REFERENCE_TO_OBJECT_MEMBER = 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 e86155f1545..e51115b54e7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -675,6 +675,7 @@ public class DefaultErrorMessages { 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(CALLABLE_REFERENCE_TO_OBJECT_MEMBER, "Callable references to object members are not supported"); 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 965e6db5dad..68fd49b2f91 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -696,6 +696,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace.report(CALLABLE_REFERENCE_TO_MEMBER_OR_EXTENSION_WITH_EMPTY_LHS.on(reference)); } + if (DescriptorUtils.isObject(descriptor.getContainingDeclaration())) { + context.trace.report(CALLABLE_REFERENCE_TO_OBJECT_MEMBER.on(reference)); + } + return CallableReferencesPackage.createReflectionTypeForResolvedCallableReference(expression, descriptor, context, components.reflectionTypes); } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/memberImportedFromObject.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/memberImportedFromObject.kt deleted file mode 100644 index 56744d67697..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/memberImportedFromObject.kt +++ /dev/null @@ -1,17 +0,0 @@ -import A.foo -import A.bar - -object A { - fun foo() = "O" - fun String.foo() = "K" - - @JvmStatic - fun bar(s: Int) = "OK" -} - -fun box(): String { - val static = (::bar)(0) - if (static != "OK") return "1" - - return (::foo)() + (String::foo)("") -} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt deleted file mode 100644 index 15191f36579..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt +++ /dev/null @@ -1,13 +0,0 @@ -object A { - var result = "Fail" - - fun foo() { - result = "OK" - } -} - -fun box(): String { - val x = A::foo - x(A) - return A.result -} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt deleted file mode 100644 index fe7f8a41b7f..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt +++ /dev/null @@ -1,13 +0,0 @@ -object A { - var result = "Fail" - - fun foo(newResult: String) { - result = newResult - } -} - -fun box(): String { - val x = A::foo - x(A, "OK") - return A.result -} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/classObjectVar.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/classObjectVar.kt deleted file mode 100644 index d263bcd7b18..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/classObjectVar.kt +++ /dev/null @@ -1,15 +0,0 @@ -class A { - companion object B { - var state: String = "12345" - } -} - -fun box(): String { - val p = A.B::state - - if (p.name != "state") return "Fail state: ${p.name}" - if (p.get(A.B) != "12345") return "Fail value: ${p.get(A.B)}" - p.set(A.B, "OK") - - return p[A.B] -} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/memberImportedFromObject.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/memberImportedFromObject.kt deleted file mode 100644 index 9cd43438f86..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/memberImportedFromObject.kt +++ /dev/null @@ -1,33 +0,0 @@ -import A.foo -import A.bar -import A.baz - -object A { - var foo = "NotOk" - var String.foo: String - get() = "K" - set(i) {} - - @JvmStatic - val bar: String = "OK" - - @JvmStatic - val String.baz: String - get() = "OK" -} - -fun box(): String { - - val static = (::bar).get() - if (static != "OK") return static - - val staticExt = (String::baz).get("a") - if (staticExt != "OK") return staticExt - - val nonExt = ::foo - - nonExt.set("O") - val ext = String::foo - ext.set("", "Whatever") - return nonExt.get() + ext.get("") -} diff --git a/compiler/testData/codegen/boxWithStdlib/intrinsics/defaultObjectMapping.kt b/compiler/testData/codegen/boxWithStdlib/intrinsics/defaultObjectMapping.kt index b133b653db0..18cc827475a 100644 --- a/compiler/testData/codegen/boxWithStdlib/intrinsics/defaultObjectMapping.kt +++ b/compiler/testData/codegen/boxWithStdlib/intrinsics/defaultObjectMapping.kt @@ -4,12 +4,15 @@ fun box(): String { assertEquals(java.lang.Integer.MIN_VALUE, Int.MIN_VALUE) assertEquals(java.lang.Byte.MAX_VALUE, Byte.MAX_VALUE) +/* +// TODO: uncomment when callable references to object members are supported assertEquals("MIN_VALUE", (Int.Companion::MIN_VALUE).name) assertEquals("MAX_VALUE", (Double.Companion::MAX_VALUE).name) assertEquals("MIN_VALUE", (Float.Companion::MIN_VALUE).name) assertEquals("MAX_VALUE", (Long.Companion::MAX_VALUE).name) assertEquals("MIN_VALUE", (Short.Companion::MIN_VALUE).name) assertEquals("MAX_VALUE", (Byte.Companion::MAX_VALUE).name) +*/ return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/jvmField/classFieldReference.kt b/compiler/testData/codegen/boxWithStdlib/jvmField/classFieldReference.kt index f76bcc7109a..10106df9287 100644 --- a/compiler/testData/codegen/boxWithStdlib/jvmField/classFieldReference.kt +++ b/compiler/testData/codegen/boxWithStdlib/jvmField/classFieldReference.kt @@ -15,6 +15,8 @@ class A(val s1: String, val s2: String) { } +/* +// TODO: uncomment when callable references to object members are supported class AWithCompanion { companion object { @JvmField public val publicField = "1"; @@ -26,10 +28,11 @@ class AWithCompanion { } } } +*/ fun box(): String { A("1", "2").testAccessors() - AWithCompanion.testAccessors() + // AWithCompanion.testAccessors() return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/jvmField/visibility.kt b/compiler/testData/codegen/boxWithStdlib/jvmField/visibility.kt index 7f8dfb892ea..77680306141 100644 --- a/compiler/testData/codegen/boxWithStdlib/jvmField/visibility.kt +++ b/compiler/testData/codegen/boxWithStdlib/jvmField/visibility.kt @@ -2,6 +2,7 @@ import java.lang.reflect.Field import kotlin.reflect.jvm.javaField +import kotlin.reflect.KProperty import kotlin.test.assertNotEquals import java.lang.reflect.Modifier @@ -32,10 +33,12 @@ class AWithCompanion { @JvmField internal val internalField = "OK"; @JvmField protected val protectedfield = "OK"; + operator fun get(name: String) = AWithCompanion.Companion::class.members.single { it.name == name } as KProperty<*> + fun testVisibilities() { - checkVisibility(AWithCompanion.Companion::publicField.javaField!!, Modifier.PUBLIC) - checkVisibility(AWithCompanion.Companion::internalField.javaField!!, Modifier.PUBLIC) - checkVisibility(AWithCompanion.Companion::protectedfield.javaField!!, Modifier.PROTECTED) + checkVisibility(this["publicField"].javaField!!, Modifier.PUBLIC) + checkVisibility(this["internalField"].javaField!!, Modifier.PUBLIC) + checkVisibility(this["protectedfield"].javaField!!, Modifier.PROTECTED) } } } @@ -45,10 +48,12 @@ object Object { @JvmField internal val internalField = "OK"; @JvmField protected val protectedfield = "OK"; + operator fun get(name: String) = Object::class.members.single { it.name == name } as KProperty<*> + fun testVisibilities() { - checkVisibility(Object::publicField.javaField!!, Modifier.PUBLIC) - checkVisibility(Object::internalField.javaField!!, Modifier.PUBLIC) - checkVisibility(Object::protectedfield.javaField!!, Modifier.PROTECTED) + checkVisibility(this["publicField"].javaField!!, Modifier.PUBLIC) + checkVisibility(this["internalField"].javaField!!, Modifier.PUBLIC) + checkVisibility(this["protectedfield"].javaField!!, Modifier.PROTECTED) } } @@ -61,4 +66,4 @@ fun box(): String { public fun checkVisibility(field: Field, visibility: Int) { assertNotEquals(field.modifiers and visibility, 0, "Field ${field} has wrong visibility") -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt b/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt deleted file mode 100644 index aaa5e3b513e..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt +++ /dev/null @@ -1,44 +0,0 @@ -import kotlin.platform.platformStatic - -object A { - - val b: String = "OK" - - @platformStatic var c: String = "Fail" - - @platformStatic fun test1() : String { - return b - } - - @platformStatic fun test2() : String { - return test1() - } - - fun test3(): String { - return "1".test5() - } - - @platformStatic fun test4(): String { - return "1".test5() - } - - @platformStatic fun String.test5() : String { - return this + b - } -} - -fun box(): String { - if ((A::test1)(A) != "OK") return "fail 1" - - if ((A::test2)(A) != "OK") return "fail 2" - - if ((A::test3)(A) != "1OK") return "fail 3" - - if ((A::test4)(A) != "1OK") return "fail 4" - - (A::c).set(A, "OK") - - if (((A::c).get(A)) != "OK") return "fail 5" - - return "OK" -} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/call/incorrectNumberOfArguments.kt b/compiler/testData/codegen/boxWithStdlib/reflection/call/incorrectNumberOfArguments.kt index f815b06826f..9265b09fb4f 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/call/incorrectNumberOfArguments.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/call/incorrectNumberOfArguments.kt @@ -1,6 +1,8 @@ import kotlin.jvm.JvmStatic as static import kotlin.reflect.jvm.isAccessible import kotlin.reflect.KCallable +import kotlin.reflect.KFunction +import kotlin.reflect.KMutableProperty var foo: String = "" @@ -11,7 +13,9 @@ class A(private var bar: String = "") { object O { private @static var baz: String = "" - @static fun getBaz() = O::baz.apply { isAccessible = true } + @static fun getBaz() = (O::class.members.single { it.name == "baz" } as KMutableProperty<*>).apply { isAccessible = true } + + fun getGetBaz() = O::class.members.single { it.name == "getBaz" } as KFunction<*> } fun check(callable: KCallable<*>, vararg args: Any?) { @@ -44,8 +48,8 @@ fun box(): String { check(::A) check(::A, null, "") - check(O::getBaz) - check(O::getBaz, null, "") + check(O.getGetBaz()) + check(O.getGetBaz(), null, "") val f = ::foo diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStatic.kt b/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStatic.kt index 1c5f0d28a86..ab668e16bf3 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStatic.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStatic.kt @@ -11,7 +11,7 @@ class C { } fun box(): String { - (Obj::foo).call(Obj) - (C.Companion::bar).call(C.Companion) + (Obj::class.members.single { it.name == "foo" }).call(Obj) + (C.Companion::class.members.single { it.name == "bar" }).call(C.Companion) return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStaticInObjectIncorrectReceiver.kt b/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStaticInObjectIncorrectReceiver.kt index 655765bbc1b..c9c482f067e 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStaticInObjectIncorrectReceiver.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/call/platformStaticInObjectIncorrectReceiver.kt @@ -4,32 +4,34 @@ object Obj { @static fun foo(s: String) {} @static fun bar() {} @static fun sly(obj: Obj) {} + + operator fun get(name: String) = Obj::class.members.single { it.name == name } } fun box(): String { // This should succeed - (Obj::foo).call(Obj, "") - (Obj::bar).call(Obj) - (Obj::sly).call(Obj, Obj) + (Obj["foo"]).call(Obj, "") + (Obj["bar"]).call(Obj) + (Obj["sly"]).call(Obj, Obj) // This shouldn't: first argument should always be Obj try { - (Obj::foo).call(null, "") + (Obj["foo"]).call(null, "") return "Fail foo" } catch (e: IllegalArgumentException) {} try { - (Obj::bar).call("") + (Obj["bar"]).call("") return "Fail bar" } catch (e: IllegalArgumentException) {} try { - (Obj::sly).call(Obj) + (Obj["sly"]).call(Obj) return "Fail sly 1" } catch (e: IllegalArgumentException) {} try { - (Obj::sly).call(null, Obj) + (Obj["sly"]).call(null, Obj) return "Fail sly 2" } catch (e: IllegalArgumentException) {} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/call/returnUnit.kt b/compiler/testData/codegen/boxWithStdlib/reflection/call/returnUnit.kt index 69a0e0e3ba6..099552c8afe 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/call/returnUnit.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/call/returnUnit.kt @@ -15,7 +15,7 @@ fun nullableUnit(unit: Boolean): Unit? = if (unit) Unit else null fun box(): String { assertEquals(Unit, ::foo.call()) assertEquals(Unit, A::bar.call(A())) - assertEquals(Unit, O::baz.call(O)) + assertEquals(Unit, O::class.members.single { it.name == "baz" }.call(O)) assertEquals(Unit, (::nullableUnit).call(true)) assertEquals(null, (::nullableUnit).call(false)) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/callBy/platformStaticInObject.kt b/compiler/testData/codegen/boxWithStdlib/reflection/callBy/platformStaticInObject.kt index e7989a4f0f7..362c6de1bfc 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/callBy/platformStaticInObject.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/callBy/platformStaticInObject.kt @@ -6,7 +6,7 @@ object Obj { } fun box(): String { - val f = Obj::foo + val f = Obj::class.members.single { it.name == "foo" } // Any object method currently requires the object instance passed try { diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/companionObjectFunction.kt b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/companionObjectFunction.kt index 33105805268..33de3fc26fd 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/companionObjectFunction.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/companionObjectFunction.kt @@ -1,4 +1,5 @@ import kotlin.jvm.JvmStatic as static +import kotlin.reflect.KFunction import kotlin.reflect.jvm.* import kotlin.test.assertEquals import kotlin.test.failsWith @@ -10,7 +11,7 @@ class C { } fun box(): String { - val foo = C.Companion::foo + val foo = C.Companion::class.members.single { it.name == "foo" } as KFunction<*> val j = foo.javaMethod ?: return "Fail: no Java method found for C::foo" assertEquals(3, j.invoke(C, "abc")) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/objectFunction.kt b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/objectFunction.kt index 2b3d1d55fe8..1519eccf781 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/objectFunction.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/platformStatic/objectFunction.kt @@ -1,4 +1,5 @@ import kotlin.jvm.JvmStatic as static +import kotlin.reflect.KFunction import kotlin.reflect.jvm.* import kotlin.test.assertEquals @@ -7,7 +8,7 @@ object O { } fun box(): String { - val foo = O::foo + val foo = O::class.members.single { it.name == "foo" } as KFunction<*> val j = foo.javaMethod ?: return "Fail: no Java method found for O::foo" assertEquals(3, j.invoke(null, "abc")) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/types/memberFunctions.kt b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/types/memberFunctions.kt index a587a6d97c5..41e5065ff4c 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/mapping/types/memberFunctions.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/mapping/types/memberFunctions.kt @@ -11,11 +11,13 @@ object O { } fun box(): String { - assertEquals(listOf(javaClass(), javaClass()), A::foo.parameters.map { it.type.javaType }) - assertEquals(listOf(javaClass(), javaClass()), O::bar.parameters.map { it.type.javaType }) + val foo = A::foo + assertEquals(listOf(javaClass(), javaClass()), foo.parameters.map { it.type.javaType }) + assertEquals(java.lang.Long.TYPE, foo.returnType.javaType) - assertEquals(java.lang.Long.TYPE, A::foo.returnType.javaType) - assertEquals(javaClass(), O::bar.returnType.javaType) + val bar = O::class.members.single { it.name == "bar" } + assertEquals(listOf(javaClass(), javaClass()), bar.parameters.map { it.type.javaType }) + assertEquals(javaClass(), bar.returnType.javaType) return "OK" } diff --git a/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.kt b/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.kt new file mode 100644 index 00000000000..4899c73d929 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION + +import Obj.ext +import A.Companion.ext2 + +object Obj { + fun foo() {} + val bar = 2 + val String.ext: String get() = this +} + +class A { + companion object { + fun foo() {} + val bar = 2 + val String.ext2: String get() = this + } +} + +fun test() { + Obj::foo + Obj::bar + String::ext + + A.Companion::foo + A.Companion::bar + String::ext2 + + A::foo + A::bar +} diff --git a/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.txt b/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.txt new file mode 100644 index 00000000000..e36b5ced850 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.txt @@ -0,0 +1,30 @@ +package + +public fun test(): 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 companion object Companion { + private constructor Companion() + public final val bar: kotlin.Int = 2 + public final val kotlin.String.ext2: 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 object Obj { + private constructor Obj() + public final val bar: kotlin.Int = 2 + public final val kotlin.String.ext: 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/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 2a365e6ab3a..5aea61388ce 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -1611,6 +1611,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("objectMembersUnsupported.kt") + public void testObjectMembersUnsupported() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/objectMembersUnsupported.kt"); + doTest(fileName); + } + @TestMetadata("unused.kt") public void testUnused() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/unused.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 74ba173df30..2b489f283ec 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -564,12 +564,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("memberImportedFromObject.kt") - public void testMemberImportedFromObject() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/memberImportedFromObject.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("nestedConstructorFromClass.kt") public void testNestedConstructorFromClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/nestedConstructorFromClass.kt"); @@ -594,18 +588,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("objectMemberUnitNoArgs.kt") - public void testObjectMemberUnitNoArgs() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("objectMemberUnitOneStringArg.kt") - public void testObjectMemberUnitOneStringArg() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("overloadedFun.kt") public void testOverloadedFun() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/overloadedFun.kt"); @@ -810,12 +792,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/callableReference/property"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("classObjectVar.kt") - public void testClassObjectVar() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/classObjectVar.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("delegated.kt") public void testDelegated() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/delegated.kt"); @@ -864,12 +840,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("memberImportedFromObject.kt") - public void testMemberImportedFromObject() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/memberImportedFromObject.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("overriddenInSubclass.kt") public void testOverriddenInSubclass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/overriddenInSubclass.kt"); @@ -2548,12 +2518,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/platformStatic"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("callableRef.kt") - public void testCallableRef() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("closure.kt") public void testClosure() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/closure.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java index efc5855e43c..ec1815a5ee4 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java @@ -114,10 +114,6 @@ public final class FunctionCallableReferenceTest extends AbstractCallableReferen checkFooBoxIsOk(); } - public void testClassMemberOverriddenInObject() throws Exception { - checkFooBoxIsOk(); - } - public void testClassMemberAndExtension() throws Exception { checkFooBoxIsOk(); } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt b/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt deleted file mode 100644 index 0ad39d5ad91..00000000000 --- a/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt +++ /dev/null @@ -1,15 +0,0 @@ -package foo - -open class A { - open fun foo(a:String,b:String): String = "fooA:" + a + b -} - -object B : A() { - override fun foo(a:String,b:String): String = "fooB:" + a + b -} - -fun box(): String { - var ref = B::foo - val result = ref(B, "1", "2") - return (if (result == "fooB:12") "OK" else result) -}