diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java new file mode 100644 index 00000000000..96daa4f378a --- /dev/null +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java @@ -0,0 +1,6 @@ +public final class C { + @kotlin.jvm.publicField + public final java.lang.String foo = "A"; + + public C() { /* compiled code */ } +} \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt new file mode 100644 index 00000000000..d6225c5a956 --- /dev/null +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt @@ -0,0 +1,5 @@ +// C + +class C { + @[kotlin.jvm.publicField] private val foo: String = "A" +} diff --git a/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java b/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java new file mode 100644 index 00000000000..846c2246310 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java @@ -0,0 +1,6 @@ +public class Test { + public static String invokeMethodWithPublicField() { + C c = new C(); + return c.foo; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt b/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt new file mode 100644 index 00000000000..798704c4d84 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt @@ -0,0 +1,7 @@ +class C { + @publicField private val foo: String = "OK" +} + +fun box(): String { + return Test.invokeMethodWithPublicField() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt new file mode 100644 index 00000000000..40e65a437de --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +class C { + + @kotlin.jvm.publicField constructor(s: String) { + + } + + @kotlin.jvm.publicField private fun foo(s: String = "OK") { + + } +} + +@kotlin.jvm.publicField +fun foo() { + @kotlin.jvm.publicField val x = "A" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt new file mode 100644 index 00000000000..2cc82a65623 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt @@ -0,0 +1,12 @@ +package + +kotlin.jvm.publicField() internal fun foo(): kotlin.Unit + +internal final class C { + kotlin.jvm.publicField() public constructor C(/*0*/ s: kotlin.String) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + kotlin.jvm.publicField() private final fun foo(/*0*/ s: kotlin.String = ...): 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/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt new file mode 100644 index 00000000000..b230058cb9e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt @@ -0,0 +1,3 @@ +class C { + private @publicField val a: String by lazy { "A" } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt new file mode 100644 index 00000000000..2bffb955537 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt @@ -0,0 +1,9 @@ +package + +internal final class C { + public constructor C() + kotlin.jvm.publicField() private final val a: kotlin.String + 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/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java index 15bd3924d0a..802450251db 100644 --- a/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java @@ -148,6 +148,12 @@ public class KotlinLightClassTestGenerated extends AbstractKotlinLightClassTest doTest(fileName); } + @TestMetadata("PublicField.kt") + public void testPublicField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt"); + doTest(fileName); + } + @TestMetadata("Synthetic.kt") public void testSynthetic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/Synthetic.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index d42fea42f26..ed32fc97ab0 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -429,6 +429,27 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest(fileName); } } + + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicField extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInPublicField() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("publicFieldNotOnProperty.kt") + public void testPublicFieldNotOnProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt"); + doTest(fileName); + } + + @TestMetadata("publicFieldOnDelegatedProperty.kt") + public void testPublicFieldOnDelegatedProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 1b873ebae00..590575d2c01 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -249,6 +249,22 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege } + @TestMetadata("compiler/testData/codegen/boxWithJava/publicField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicField extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInPublicField() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/publicField"), Pattern.compile("^([^\\.]+)$"), true); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/publicField/simple/"); + doTestWithJava(fileName); + } + + } + @TestMetadata("compiler/testData/codegen/boxWithJava/reflection") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)