JS: prohibit native (external) extension properties and functions. See KT-13896
This commit is contained in:
+3
-17
@@ -1,19 +1,5 @@
|
||||
package foo
|
||||
|
||||
// HACKS
|
||||
|
||||
external const val PATH_TO_F_CREATOR = "B\$far\$lambda"
|
||||
external const val PATH_TO_G_CREATOR = "B\$gar\$lambda"
|
||||
|
||||
@JsName("$PATH_TO_F_CREATOR")
|
||||
external val F_CREATOR: Any = noImpl
|
||||
|
||||
@JsName("$PATH_TO_G_CREATOR")
|
||||
external val G_CREATOR: Any = noImpl
|
||||
|
||||
|
||||
// Test
|
||||
|
||||
open class A {
|
||||
fun foo() = "A::foo"
|
||||
}
|
||||
@@ -34,8 +20,8 @@ fun box(): String {
|
||||
assertEquals("A::foo", f())
|
||||
assertEquals("B::boo", g())
|
||||
|
||||
val fs = F_CREATOR.toString()
|
||||
val gs = G_CREATOR.toString().replaceAll("boo", "foo").replaceAll("gar", "far")
|
||||
val fs = js("B\$far\$lambda").toString() as String
|
||||
val gs = (js("B\$gar\$lambda").toString() as String).replaceAll("boo", "foo").replaceAll("gar", "far")
|
||||
|
||||
assertEquals(gs, fs)
|
||||
|
||||
@@ -45,7 +31,7 @@ fun box(): String {
|
||||
|
||||
// Helpers
|
||||
|
||||
external fun String.replace(regexp: RegExp, replacement: String): String = noImpl
|
||||
inline fun String.replace(regexp: RegExp, replacement: String): String = asDynamic().replace(regexp, replacement)
|
||||
|
||||
fun String.replaceAll(regexp: String, replacement: String): String = replace(RegExp(regexp, "g"), replacement)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user