diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 7b8f5c62c04..00d9130261d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13724,6 +13724,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("NameHighlighter.kt") + public void testNameHighlighter() throws Exception { + runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); + } + @Test @TestMetadata("SuspendExtension.kt") public void testSuspendExtension() throws Exception { diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index 2787ce4a395..a9e641b8747 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -714,11 +714,12 @@ class FirElementSerializer private constructor( private fun getAccessorFlags(accessor: FirPropertyAccessor, property: FirProperty): Int { // [FirDefaultPropertyAccessor]---a property accessor without body---can still hold other information, such as annotations, // user-contributed visibility, and modifiers, such as `external` or `inline`. + val nonSourceAnnotations = accessor.nonSourceAnnotations(session) val isDefault = accessor is FirDefaultPropertyAccessor && - accessor.annotations.isEmpty() && accessor.visibility == property.visibility && + nonSourceAnnotations.isEmpty() && accessor.visibility == property.visibility && !accessor.isExternal && !accessor.isInline return Flags.getAccessorFlags( - accessor.nonSourceAnnotations(session).isNotEmpty(), + nonSourceAnnotations.isNotEmpty(), ProtoEnumFlags.visibility(normalizeVisibility(accessor)), ProtoEnumFlags.modality(accessor.modality!!), !isDefault, diff --git a/compiler/testData/codegen/box/fir/NameHighlighter.kt b/compiler/testData/codegen/box/fir/NameHighlighter.kt new file mode 100644 index 00000000000..83a2488e240 --- /dev/null +++ b/compiler/testData/codegen/box/fir/NameHighlighter.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JVM +// MODULE: lib +// FILE: NameHighlighter.kt + +object NameHighlighter { + var namesHighlightingEnabled = true + @TestOnly set +} + +// FILE: TestOnly.java + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.SOURCE) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface TestOnly { +} + +// MODULE: main(lib) +// FILE: main.kt + +fun box(): String { + if (!NameHighlighter.namesHighlightingEnabled) return "FAIL 1" + NameHighlighter.namesHighlightingEnabled = false + if (NameHighlighter.namesHighlightingEnabled) return "FAIL 2" + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index a2e3a1b2235..18fb78c7125 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13724,6 +13724,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("NameHighlighter.kt") + public void testNameHighlighter() throws Exception { + runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); + } + @Test @TestMetadata("SuspendExtension.kt") public void testSuspendExtension() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index c3c4540ed55..636b5fd5453 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13724,6 +13724,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("NameHighlighter.kt") + public void testNameHighlighter() throws Exception { + runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); + } + @Test @TestMetadata("SuspendExtension.kt") public void testSuspendExtension() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index f0760698a5d..baf97abc09c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12061,6 +12061,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testIrBuiltIns() throws Exception { runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + + @TestMetadata("NameHighlighter.kt") + public void testNameHighlighter() throws Exception { + runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt"); + } } @TestMetadata("compiler/testData/codegen/box/fullJdk")