From 8ab55813fe95a7b6b22b7bc8583f40270fc54d6e Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 16 Oct 2015 15:28:04 +0300 Subject: [PATCH] Dropping package facades: - clashing JVM signature diagnostics should be reported in stable order - drop tests for clashes vs package facades - introduce box test for class named as old package facade - fix some testData --- .../diagnostics/DefaultErrorMessagesJvm.java | 13 ++++++++++-- .../testData/cli/jvm/classAndFacadeClash.args | 3 --- .../testData/cli/jvm/classAndFacadeClash.kt | 10 ---------- .../testData/cli/jvm/classAndFacadeClash.out | 1 - compiler/testData/cli/jvm/extraHelp.out | 1 - .../cli/jvm/fileClassAndFacadeClash.args | 3 --- .../cli/jvm/fileClassAndFacadeClash.kt | 4 ---- .../cli/jvm/fileClassAndFacadeClash.out | 1 - compiler/testData/cli/jvm/signatureClash.out | 10 +++++----- .../jvm/syntheticAccessorSignatureClash.out | 20 +++++++++---------- .../classes/classNamedAsOldPackageFacade.kt | 7 +++++++ .../cli/KotlincExecutableTestGenerated.java | 12 ----------- .../BlackBoxCodegenTestGenerated.java | 6 ++++++ .../inheritedTopLevel/annotations.txt | 2 -- 14 files changed, 39 insertions(+), 54 deletions(-) delete mode 100644 compiler/testData/cli/jvm/classAndFacadeClash.args delete mode 100644 compiler/testData/cli/jvm/classAndFacadeClash.kt delete mode 100644 compiler/testData/cli/jvm/classAndFacadeClash.out delete mode 100644 compiler/testData/cli/jvm/fileClassAndFacadeClash.args delete mode 100644 compiler/testData/cli/jvm/fileClassAndFacadeClash.kt delete mode 100644 compiler/testData/cli/jvm/fileClassAndFacadeClash.out create mode 100644 compiler/testData/codegen/box/classes/classNamedAsOldPackageFacade.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 00b4dc73084..6f5ee083e49 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -24,19 +24,28 @@ import org.jetbrains.kotlin.diagnostics.rendering.Renderers; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.renderer.Renderer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { private static final Renderer CONFLICTING_JVM_DECLARATIONS_DATA = new Renderer() { @NotNull @Override public String render(@NotNull ConflictingJvmDeclarationsData data) { - StringBuilder sb = new StringBuilder(); + List renderedDescriptors = new ArrayList(); for (JvmDeclarationOrigin origin : data.getSignatureOrigins()) { DeclarationDescriptor descriptor = origin.getDescriptor(); if (descriptor != null) { - sb.append(" ").append(DescriptorRenderer.COMPACT.render(descriptor)).append("\n"); + renderedDescriptors.add(DescriptorRenderer.Companion.getCOMPACT().render(descriptor)); } } + Collections.sort(renderedDescriptors); + StringBuilder sb = new StringBuilder(); + for (String renderedDescriptor : renderedDescriptors) { + sb.append(" ").append(renderedDescriptor).append("\n"); + } return ("The following declarations have the same JVM signature (" + data.getSignature().getName() + data.getSignature().getDesc() + "):\n" + sb).trim(); } }; diff --git a/compiler/testData/cli/jvm/classAndFacadeClash.args b/compiler/testData/cli/jvm/classAndFacadeClash.args deleted file mode 100644 index b22faf6a45a..00000000000 --- a/compiler/testData/cli/jvm/classAndFacadeClash.args +++ /dev/null @@ -1,3 +0,0 @@ -$TESTDATA_DIR$/classAndFacadeClash.kt --d -$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/classAndFacadeClash.kt b/compiler/testData/cli/jvm/classAndFacadeClash.kt deleted file mode 100644 index ee7dbf1efa8..00000000000 --- a/compiler/testData/cli/jvm/classAndFacadeClash.kt +++ /dev/null @@ -1,10 +0,0 @@ -package test - -class TestPackage { - -} - - -fun z () { - -} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/classAndFacadeClash.out b/compiler/testData/cli/jvm/classAndFacadeClash.out deleted file mode 100644 index a0aba9318ad..00000000000 --- a/compiler/testData/cli/jvm/classAndFacadeClash.out +++ /dev/null @@ -1 +0,0 @@ -OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index b9be78ed962..5bc3a7a881d 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -3,7 +3,6 @@ where advanced options include: -Xno-call-assertions Don't generate not-null assertion after each invocation of method returning not-null -Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java -Xno-optimize Disable optimizations - -Xmultifile-package-facadesCompile package facade classes as multifile classes -Xreport-perf Report detailed performance statistics -Xno-inline Disable method inlining -Xrepeat Repeat compilation (for performance analysis) diff --git a/compiler/testData/cli/jvm/fileClassAndFacadeClash.args b/compiler/testData/cli/jvm/fileClassAndFacadeClash.args deleted file mode 100644 index 61420d21be3..00000000000 --- a/compiler/testData/cli/jvm/fileClassAndFacadeClash.args +++ /dev/null @@ -1,3 +0,0 @@ -$TESTDATA_DIR$/fileClassAndFacadeClash.kt --d -$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/fileClassAndFacadeClash.kt b/compiler/testData/cli/jvm/fileClassAndFacadeClash.kt deleted file mode 100644 index 26faeb59b77..00000000000 --- a/compiler/testData/cli/jvm/fileClassAndFacadeClash.kt +++ /dev/null @@ -1,4 +0,0 @@ -@file:JvmName("TestPackage") -package test - -fun foo() {} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/fileClassAndFacadeClash.out b/compiler/testData/cli/jvm/fileClassAndFacadeClash.out deleted file mode 100644 index a0aba9318ad..00000000000 --- a/compiler/testData/cli/jvm/fileClassAndFacadeClash.out +++ /dev/null @@ -1 +0,0 @@ -OK \ No newline at end of file diff --git a/compiler/testData/cli/jvm/signatureClash.out b/compiler/testData/cli/jvm/signatureClash.out index bd85247ba89..4da783611e4 100644 --- a/compiler/testData/cli/jvm/signatureClash.out +++ b/compiler/testData/cli/jvm/signatureClash.out @@ -1,26 +1,26 @@ compiler/testData/cli/jvm/signatureClash.kt:6:5: error: accidental override: The following declarations have the same JVM signature (getX()I): - fun getX(): kotlin.Int fun (): kotlin.Int + fun getX(): kotlin.Int fun getX() = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:8:5: error: platform declaration clash: The following declarations have the same JVM signature (getA()I): - fun getA(): kotlin.Int fun (): kotlin.Int + fun getA(): kotlin.Int fun getA(): Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:9:5: error: platform declaration clash: The following declarations have the same JVM signature (getA()I): - fun getA(): kotlin.Int fun (): kotlin.Int + fun getA(): kotlin.Int val a: Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:12:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I): - fun getB(): kotlin.Int fun (): kotlin.Int + fun getB(): kotlin.Int fun getB(): Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:13:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I): - fun getB(): kotlin.Int fun (): kotlin.Int + fun getB(): kotlin.Int val b: Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:19:7: error: platform declaration clash: The following declarations have the same JVM signature (getTr()I): diff --git a/compiler/testData/cli/jvm/syntheticAccessorSignatureClash.out b/compiler/testData/cli/jvm/syntheticAccessorSignatureClash.out index 6ac970558dc..deef4398ba7 100644 --- a/compiler/testData/cli/jvm/syntheticAccessorSignatureClash.out +++ b/compiler/testData/cli/jvm/syntheticAccessorSignatureClash.out @@ -3,29 +3,29 @@ compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:15:5: error: accide fun foo(): kotlin.Unit private fun foo() {} ^ -compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:18:9: error: accidental override: The following declarations have the same JVM signature (access$getBar$p(LDerived;)I): - fun `access$getBar$p`(d: Derived): kotlin.Int +compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:18:9: error: accidental override: The following declarations have the same JVM signature (access$getBar$1(LDerived;)I): fun (): kotlin.Int + fun `access$getBar$1`(d: Derived): kotlin.Int get ^ -compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:19:9: error: accidental override: The following declarations have the same JVM signature (access$setBar$p(LDerived;I)V): - fun `access$setBar$p`(d: Derived, i: kotlin.Int): kotlin.Unit +compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:19:9: error: accidental override: The following declarations have the same JVM signature (access$setBar$1(LDerived;I)V): fun (: kotlin.Int): kotlin.Unit + fun `access$setBar$1`(d: Derived, i: kotlin.Int): kotlin.Unit set ^ -compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:21:5: error: accidental override: The following declarations have the same JVM signature (access$getBaz$p(LDerived;)I): - fun `access$getBaz$p`(d: Derived): kotlin.Int +compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:21:5: error: accidental override: The following declarations have the same JVM signature (access$getBaz$2(LDerived;)I): fun (): kotlin.Int + fun `access$getBaz$2`(d: Derived): kotlin.Int private var baz = 1 ^ -compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:23:5: error: accidental override: The following declarations have the same JVM signature (access$getBoo$p(LDerived;)I): - fun `access$getBoo$p`(d: Derived): kotlin.Int +compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:23:5: error: accidental override: The following declarations have the same JVM signature (access$getBoo$3(LDerived;)I): fun (): kotlin.Int + fun `access$getBoo$3`(d: Derived): kotlin.Int private val boo = 1 ^ -compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:27:9: error: accidental override: The following declarations have the same JVM signature (access$setBar1$p(LDerived;I)V): - fun `access$setBar1$p`(d: Derived, i: kotlin.Int): kotlin.Unit +compiler/testData/cli/jvm/syntheticAccessorSignatureClash.kt:27:9: error: accidental override: The following declarations have the same JVM signature (access$setBar1$4(LDerived;I)V): fun (: kotlin.Int): kotlin.Unit + fun `access$setBar1$4`(d: Derived, i: kotlin.Int): kotlin.Unit set ^ COMPILATION_ERROR \ No newline at end of file diff --git a/compiler/testData/codegen/box/classes/classNamedAsOldPackageFacade.kt b/compiler/testData/codegen/box/classes/classNamedAsOldPackageFacade.kt new file mode 100644 index 00000000000..24c2efdc564 --- /dev/null +++ b/compiler/testData/codegen/box/classes/classNamedAsOldPackageFacade.kt @@ -0,0 +1,7 @@ +package test + +class TestPackage { + val OK = "OK" +} + +fun box(): String = TestPackage().OK \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java index ed964a58543..a6062d5697d 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java @@ -37,12 +37,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cli/jvm"), Pattern.compile("^(.+)\\.args$"), false); } - @TestMetadata("classAndFacadeClash.args") - public void testClassAndFacadeClash() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndFacadeClash.args"); - doJvmTest(fileName); - } - @TestMetadata("classAndFileClassClash.args") public void testClassAndFileClassClash() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/classAndFileClassClash.args"); @@ -109,12 +103,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJvmTest(fileName); } - @TestMetadata("fileClassAndFacadeClash.args") - public void testFileClassAndFacadeClash() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/fileClassAndFacadeClash.args"); - doJvmTest(fileName); - } - @TestMetadata("fileClassAndMultifileClassClash.args") public void testFileClassAndMultifileClassClash() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/fileClassAndMultifileClassClash.args"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 5a6b03a7601..7d84f66bd3d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -1036,6 +1036,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("classNamedAsOldPackageFacade.kt") + public void testClassNamedAsOldPackageFacade() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/classNamedAsOldPackageFacade.kt"); + doTest(fileName); + } + @TestMetadata("classObject.kt") public void testClassObject() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/classes/classObject.kt"); diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt index b7fe5f88b2a..1f43cf9ea09 100644 --- a/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt @@ -2,5 +2,3 @@ p org.test 0 d 0/InheritedTopLevelKt a org.jetbrains.annotations.NotNull 0 m 0 0/InheritedTopLevelKt getTopLevelProperty -d 0/TestPackage -m 0 0/TestPackage getTopLevelProperty