From 4609b111026dea0f8e72ecf16c3a9d15c59bff1e Mon Sep 17 00:00:00 2001 From: Alexander Korepanov Date: Mon, 18 Dec 2023 16:38:10 +0100 Subject: [PATCH] [JS FIR] Add JsName clash test ^KT-64364 --- .../name/companionInheritsOwnerClass.kt | 15 +++++++++++ .../name/companionInheritsOwnerClass.txt | 27 +++++++++++++++++++ ...JsOldFrontendDiagnosticsTestGenerated.java | 6 +++++ .../DiagnosticsWithJsStdLibTestGenerated.java | 6 +++++ 4 files changed, 54 insertions(+) create mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt create mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.txt diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt new file mode 100644 index 00000000000..877527b2422 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt @@ -0,0 +1,15 @@ +// !OPT_IN: kotlin.js.ExperimentalJsExport +// FIR_IDENTICAL +@file:JsExport + +interface Optional { + @JsName("valueOrThrowException") + fun valueOrThrow(exp: Throwable): T + + fun valueOrThrow(): T = valueOrThrow(NoSuchElementException("Optional has no value")) +} + +abstract class None private constructor() : Optional { + companion object : None() + override fun valueOrThrow(exp: Throwable): Nothing = throw exp +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.txt new file mode 100644 index 00000000000..f0b1f63b41d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.txt @@ -0,0 +1,27 @@ +package + +public abstract class None : Optional { + private constructor None() + 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 open override /*1*/ /*fake_override*/ fun valueOrThrow(): T + public open override /*1*/ fun valueOrThrow(/*0*/ exp: kotlin.Throwable): kotlin.Nothing + + public companion object Companion : None { + private constructor Companion() + 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 open override /*1*/ /*fake_override*/ fun valueOrThrow(): kotlin.Nothing + public open override /*1*/ /*fake_override*/ fun valueOrThrow(/*0*/ exp: kotlin.Throwable): kotlin.Nothing + } +} + +public interface Optional { + 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 open fun valueOrThrow(): T + @kotlin.js.JsName(name = "valueOrThrowException") public abstract fun valueOrThrow(/*0*/ exp: kotlin.Throwable): T +} diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java index e68e1de33f7..23914acc1a1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java @@ -688,6 +688,12 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ runTest("compiler/testData/diagnostics/testsWithJsStdLib/name/classMembers.kt"); } + @Test + @TestMetadata("companionInheritsOwnerClass.kt") + public void testCompanionInheritsOwnerClass() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt"); + } + @Test @TestMetadata("conflictingNamesFromSuperclass.kt") public void testConflictingNamesFromSuperclass() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java index 64420381efb..aec81cc9282 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/DiagnosticsWithJsStdLibTestGenerated.java @@ -688,6 +688,12 @@ public class DiagnosticsWithJsStdLibTestGenerated extends AbstractDiagnosticsTes runTest("compiler/testData/diagnostics/testsWithJsStdLib/name/classMembers.kt"); } + @Test + @TestMetadata("companionInheritsOwnerClass.kt") + public void testCompanionInheritsOwnerClass() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/name/companionInheritsOwnerClass.kt"); + } + @Test @TestMetadata("conflictingNamesFromSuperclass.kt") public void testConflictingNamesFromSuperclass() throws Exception {