Revert "Temporarily remove JvmPackageName and tests, but keep the implementation"

This reverts commit 9ae6feb2c5.
This commit is contained in:
Alexander Udalov
2017-09-15 20:15:40 +03:00
committed by Ilya Gorbunov
parent 00be512532
commit 7f8634d9ef
35 changed files with 498 additions and 0 deletions
@@ -0,0 +1,18 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// LANGUAGE_VERSION: 1.2
// FILE: foo.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("jjj")
fun f(): String = "O"
val g: String? get() = "K"
inline fun i(block: () -> String) = block()
// FILE: bar.kt
fun box(): String = i { f() + g }
+21
View File
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// LANGUAGE_VERSION: 1.2
// FILE: foo.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
package foo.bar
fun f(): String = "O"
val g: String? get() = "K"
inline fun <T> i(block: () -> T): T = block()
// FILE: bar.kt
import foo.bar.*
fun box(): String = i { f() + g }
@@ -0,0 +1,19 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// LANGUAGE_VERSION: 1.2
// FILE: foo.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("jjj")
@file:JvmName("Foooo")
fun f(): String = "O"
val g: String? get() = "K"
inline fun i(block: () -> String) = block()
// FILE: bar.kt
fun box(): String = i { f() + g }
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// LANGUAGE_VERSION: 1.2
// FILE: 1.kt
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:JvmPackageName("baz.foo.quux.bar")
package foo.bar
fun f(): String = "O"
val g: String? get() = "K"
inline fun <T> i(block: () -> T): T = block()
// FILE: 2.kt
import foo.bar.*
fun box(): String = i { f() + g }
@@ -0,0 +1,26 @@
// IGNORE_BACKEND: NATIVE
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("bar")
package foo
fun f() = "OK"
var v: Int = 1
inline fun i(block: () -> Unit) = block()
// FILE: B.kt
// LANGUAGE_VERSION: 1.2
import foo.*
fun box(): String {
v = 2
if (v != 2) return "Fail"
i { v = 3 }
if (v != 3) return "Fail"
return f()
}
@@ -0,0 +1,19 @@
// IGNORE_BACKEND: NATIVE
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("bar")
fun f() = "OK"
var v: Int = 1
// FILE: B.kt
// LANGUAGE_VERSION: 1.2
fun box(): String {
v = 2
if (v != 2) return "Fail"
return f()
}
@@ -0,0 +1,23 @@
// IGNORE_BACKEND: NATIVE
// FILE: A.kt
// LANGUAGE_VERSION: 1.2
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("bar")
@file:JvmName("Baz")
package foo
fun f() = "OK"
var v: Int = 1
// FILE: B.kt
// LANGUAGE_VERSION: 1.2
import foo.*
fun box(): String {
v = 2
if (v != 2) return "Fail"
return f()
}
@@ -0,0 +1,34 @@
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE
// !API_VERSION: 1.2
// FILE: a.kt
<!JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_MULTIFILE_CLASSES!>@file:JvmPackageName("a")<!>
@file:JvmMultifileClass
package a
fun a() {}
// FILE: b.kt
<!JVM_PACKAGE_NAME_CANNOT_BE_EMPTY!>@file:JvmPackageName("")<!>
package b
fun b() {}
// FILE: c.kt
<!JVM_PACKAGE_NAME_MUST_BE_VALID_NAME!>@file:JvmPackageName("invalid-fq-name")<!>
package c
fun c() {}
// FILE: d.kt
<!JVM_PACKAGE_NAME_NOT_SUPPORTED_IN_FILES_WITH_CLASSES!>@file:JvmPackageName("d")<!>
package d
class D
fun d() {}
// FILE: e.kt
@file:JvmPackageName(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>)
package e
fun e() {}
// FILE: f.kt
@file:JvmPackageName(<!EXPRESSION_EXPECTED_PACKAGE_FOUND!>f<!>)
package f
const val name = "f"
@@ -0,0 +1,32 @@
package
package a {
public fun a(): kotlin.Unit
}
package b {
public fun b(): kotlin.Unit
}
package c {
public fun c(): kotlin.Unit
}
package d {
public fun d(): kotlin.Unit
public final class D {
public constructor D()
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
}
}
package e {
public fun e(): kotlin.Unit
}
package f {
public const val name: kotlin.String = "f"
}
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j")
package bar
fun file0() {}
@@ -0,0 +1,6 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("JJ")
@file:JvmPackageName("jj")
package bar
fun jj() {}
@@ -0,0 +1,3 @@
package foo
fun file1() {}
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("jjj")
package foo
fun file2() {}
@@ -0,0 +1,5 @@
@file:JvmMultifileClass
@file:JvmName("MultiFoo")
package foo
fun multiFile1() {}
@@ -0,0 +1,7 @@
bar
j/BarAsJKt
jj/JJ
foo
foo/MultiFoo__FooMultiFileKt (foo/MultiFoo)
foo/FooKt
jjj/FooAsJJJKt
@@ -0,0 +1,3 @@
package foo
fun file1() {}
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("j")
package foo
fun file2() {}
@@ -0,0 +1,2 @@
foo
foo/FooKt
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("foo.jvm")
package foo
fun foo1() {}
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("foo.jvm")
package foo
fun foo2() {}
@@ -0,0 +1,5 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmPackageName("foo.jvm")
package foo
fun foo3() {}
@@ -0,0 +1,4 @@
foo
foo/jvm/Foo1Kt
foo/jvm/Foo2Kt
foo/jvm/Foo3Kt
@@ -10560,6 +10560,33 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@TestMetadata("compiler/testData/codegen/box/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractIrBlackBoxCodegenTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/simple.kt");
doTest(fileName);
}
@TestMetadata("withJvmName.kt")
public void testWithJvmName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/withJvmName.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/jvmStatic")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1587,6 +1587,21 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
}
}
@TestMetadata("compiler/testData/codegen/boxInline/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractIrBlackBoxInlineCodegenTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/jvmPackageName/simple.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/lambdaClassClash")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1587,6 +1587,21 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
}
}
@TestMetadata("compiler/testData/codegen/boxInline/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractIrCompileKotlinAgainstInlineKotlinTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/jvmPackageName/simple.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/lambdaClassClash")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -554,6 +554,21 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractDiagnosticsTestWithStdLib {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("incorrectJvmPackageName.kt")
public void testIncorrectJvmPackageName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -520,6 +520,21 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmOverloads"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractDiagnosticsTestWithStdLibUsingJavac {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("incorrectJvmPackageName.kt")
public void testIncorrectJvmPackageName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmPackageName/incorrectJvmPackageName.kt");
doTest(fileName);
}
}
@TestMetadata("JvmOverloadWithNoDefaults.kt")
public void testJvmOverloadWithNoDefaults() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmOverloads/JvmOverloadWithNoDefaults.kt");
@@ -10560,6 +10560,33 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/simple.kt");
doTest(fileName);
}
@TestMetadata("withJvmName.kt")
public void testWithJvmName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/withJvmName.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/jvmStatic")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1587,6 +1587,21 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
}
}
@TestMetadata("compiler/testData/codegen/boxInline/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractBlackBoxInlineCodegenTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/jvmPackageName/simple.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/lambdaClassClash")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1587,6 +1587,21 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
}
}
@TestMetadata("compiler/testData/codegen/boxInline/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractCompileKotlinAgainstInlineKotlinTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/jvmPackageName/simple.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/lambdaClassClash")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -138,6 +138,24 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
doTest(fileName);
}
@TestMetadata("jvmPackageName.kt")
public void testJvmPackageName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/jvmPackageName.kt");
doTest(fileName);
}
@TestMetadata("jvmPackageNameInRootPackage.kt")
public void testJvmPackageNameInRootPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/jvmPackageNameInRootPackage.kt");
doTest(fileName);
}
@TestMetadata("jvmPackageNameWithJvmName.kt")
public void testJvmPackageNameWithJvmName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/jvmPackageNameWithJvmName.kt");
doTest(fileName);
}
@TestMetadata("jvmStaticInObject.kt")
public void testJvmStaticInObject() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/jvmStaticInObject.kt");
@@ -76,4 +76,19 @@ class JvmPackageTableTest : KtUsefulTestCase() {
fun testSimple() {
doTest("/jvmPackageTable/simple")
}
fun testJvmPackageName() {
doTest("/jvmPackageTable/jvmPackageName",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_2)
}
fun testJvmPackageNameManyParts() {
doTest("/jvmPackageTable/jvmPackageNameManyParts",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_2)
}
fun testJvmPackageNameLanguageVersion11() {
doTest("/jvmPackageTable/jvmPackageNameLanguageVersion11",
compileWith = LanguageVersion.KOTLIN_1_2, loadWith = LanguageVersion.KOTLIN_1_1)
}
}
@@ -10560,6 +10560,33 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractLightAnalysisModeTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("rootPackage.kt")
public void testRootPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/rootPackage.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/simple.kt");
doTest(fileName);
}
@TestMetadata("withJvmName.kt")
public void testWithJvmName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmPackageName/withJvmName.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/jvmStatic")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -62,6 +62,18 @@ public annotation class JvmName(val name: String)
@MustBeDocumented
public annotation class JvmMultifileClass
/**
* Changes the fully qualified name of the JVM package of the .class file generated from this file.
* This does not affect the way Kotlin clients will see the declarations in this file, but Java clients and other JVM language clients
* will see the class file as if it was declared in the specified package.
* If a file is annotated with this annotation, it can only have function, property and typealias declarations, but no classes.
*/
@Target(AnnotationTarget.FILE)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
@SinceKotlin("1.2")
internal annotation class JvmPackageName(val name: String)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.SOURCE)
public annotation class JvmSynthetic
@@ -11802,6 +11802,15 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
}
}
@TestMetadata("compiler/testData/codegen/box/jvmPackageName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JvmPackageName extends AbstractJsCodegenBoxTest {
public void testAllFilesPresentInJvmPackageName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/jvmPackageName"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
}
@TestMetadata("compiler/testData/codegen/box/jvmStatic")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)