[JS IR] Export protected members too
#KT-47524 Fixed #KT-47525 Fixed
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1265
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// INFER_MAIN_MODULE
|
||||
// SKIP_MINIFICATION
|
||||
// SKIP_NODE_JS
|
||||
// SKIP_DCE_DRIVEN
|
||||
|
||||
// MODULE: exportProtectedMembers
|
||||
// FILE: lib.kt
|
||||
|
||||
@JsExport
|
||||
open class Foo protected constructor() {
|
||||
protected fun bar(): String = "protected method"
|
||||
|
||||
private var _baz: String = "baz"
|
||||
|
||||
protected var baz: String
|
||||
get() = _baz
|
||||
set(value) {
|
||||
_baz = value
|
||||
}
|
||||
|
||||
protected class NestedClass {
|
||||
val prop: String = "nested class property"
|
||||
}
|
||||
protected object NestedObject {
|
||||
val prop: String = "nested object property"
|
||||
}
|
||||
|
||||
protected companion object {
|
||||
val prop: String = "companion object property"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.js
|
||||
function box() {
|
||||
foo = new exportProtectedMembers.Foo();
|
||||
|
||||
if (foo.bar() != 'protected method') return 'failed to call protected method';
|
||||
if (foo.baz != 'baz') return 'failed to read protected property';
|
||||
foo.baz = 'beer';
|
||||
if (foo.baz != 'beer') return 'failed to write protected property';
|
||||
|
||||
nestedClass = new exportProtectedMembers.Foo.NestedClass()
|
||||
if (nestedClass.prop != 'nested class property')
|
||||
return 'failed to read protected class property'
|
||||
if (exportProtectedMembers.Foo.NestedObject.prop != 'nested object property')
|
||||
return 'failed to read protected nested object property'
|
||||
if (exportProtectedMembers.Foo.Companion.prop != 'companion object property')
|
||||
return 'failed to read protected companion object property'
|
||||
|
||||
return 'OK';
|
||||
}
|
||||
@@ -9,10 +9,24 @@ declare namespace JS_TESTS {
|
||||
}
|
||||
class Class {
|
||||
constructor();
|
||||
protected readonly protectedVal: number;
|
||||
protected protectedFun(): number;
|
||||
protected readonly protectedNestedObject: {
|
||||
};
|
||||
protected readonly Companion: {
|
||||
readonly companionObjectProp: number;
|
||||
};
|
||||
readonly publicVal: number;
|
||||
publicFun(): number;
|
||||
}
|
||||
namespace Class {
|
||||
class protectedClass {
|
||||
constructor();
|
||||
}
|
||||
class classWithProtectedConstructors {
|
||||
protected constructor();
|
||||
protected static createWithString(arg: string): Class.classWithProtectedConstructors;
|
||||
}
|
||||
class publicClass {
|
||||
constructor();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,17 @@ open class Class {
|
||||
|
||||
protected val protectedVal = 10
|
||||
protected fun protectedFun() = 10
|
||||
protected class protectedClass
|
||||
protected class protectedClass {}
|
||||
protected object protectedNestedObject {}
|
||||
protected companion object {
|
||||
val companionObjectProp = 10
|
||||
}
|
||||
|
||||
public class classWithProtectedConstructors protected constructor() {
|
||||
|
||||
@JsName("createWithString")
|
||||
protected constructor(arg: String): this()
|
||||
}
|
||||
|
||||
public val publicVal = 10
|
||||
@JsName("publicFun") // TODO: Should work without JsName
|
||||
|
||||
Reference in New Issue
Block a user