rra/ilgonmic/more-tests-for-internal-export
[JS IR] Add single file test [JS IR] isExportedMember considers only public API [JS IR] Add case with non default accessor Merge-request: KT-MR-6008 Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com> ^KT-50504 fixed
This commit is contained in:
@@ -5,16 +5,18 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.utils
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.isInterface
|
||||
import org.jetbrains.kotlin.descriptors.isClass
|
||||
import org.jetbrains.kotlin.descriptors.isInterface
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithVisibility
|
||||
import org.jetbrains.kotlin.ir.expressions.IrReturn
|
||||
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
|
||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||
|
||||
fun IrDeclaration.isExportedMember() =
|
||||
parentClassOrNull.let { it is IrClass && it.isJsExport() }
|
||||
(this is IrDeclarationWithVisibility && visibility.isPublicAPI) &&
|
||||
parentClassOrNull.let { it is IrClass && it.isJsExport() }
|
||||
|
||||
fun IrDeclaration?.isExportedClass() =
|
||||
this is IrClass && kind.isClass && isJsExport()
|
||||
|
||||
@@ -2094,6 +2094,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/export/exportClassWithInternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportClassWithInternalOneFile.kt")
|
||||
public void testExportClassWithInternalOneFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/exportClassWithInternalOneFile.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportEnumClass.kt")
|
||||
public void testExportEnumClass() throws Exception {
|
||||
|
||||
+6
@@ -2496,6 +2496,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/export/exportClassWithInternal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportClassWithInternalOneFile.kt")
|
||||
public void testExportClassWithInternalOneFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/exportClassWithInternalOneFile.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportEnumClass.kt")
|
||||
public void testExportEnumClass() throws Exception {
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
// FILE: lib.kt
|
||||
@JsExport
|
||||
class Foo(internal val constructorParameter: String)
|
||||
class Foo(internal val constructorParameter: String) {
|
||||
internal val nonDefaultAccessor: String
|
||||
get() = "hello"
|
||||
|
||||
internal val defaultAccessor: String = constructorParameter + "!"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
enum class Bar(internal val constructorParameter: String) {
|
||||
A("a");
|
||||
|
||||
internal val nonDefaultAccessor: String
|
||||
get() = "hello"
|
||||
|
||||
internal val defaultAccessor: String = constructorParameter + "!"
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun box():String {
|
||||
fun box(): String {
|
||||
val foo = Foo("foo")
|
||||
if (foo.constructorParameter != "foo") return "fail"
|
||||
if (foo.constructorParameter != "foo") return "fail1"
|
||||
if (foo.nonDefaultAccessor != "hello") return "fail2"
|
||||
if (foo.defaultAccessor != "foo!") return "fail3"
|
||||
|
||||
if (Bar.A.constructorParameter != "a") return "fail4"
|
||||
if (Bar.A.nonDefaultAccessor != "hello") return "fail5"
|
||||
if (Bar.A.defaultAccessor != "a!") return "fail6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
@JsExport
|
||||
class Foo(internal val constructorParameter: String) {
|
||||
internal val nonDefaultAccessor: String
|
||||
get() = "hello"
|
||||
|
||||
internal val defaultAccessor: String = constructorParameter + "!"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
enum class Bar(internal val constructorParameter: String) {
|
||||
A("a");
|
||||
|
||||
internal val nonDefaultAccessor: String
|
||||
get() = "hello"
|
||||
|
||||
internal val defaultAccessor: String = constructorParameter + "!"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = Foo("foo")
|
||||
if (foo.constructorParameter != "foo") return "fail1"
|
||||
if (foo.nonDefaultAccessor != "hello") return "fail2"
|
||||
if (foo.defaultAccessor != "foo!") return "fail3"
|
||||
|
||||
if (Bar.A.constructorParameter != "a") return "fail4"
|
||||
if (Bar.A.nonDefaultAccessor != "hello") return "fail5"
|
||||
if (Bar.A.defaultAccessor != "a!") return "fail6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user