JS: prohibit native (external) extension properties and functions. See KT-13896

This commit is contained in:
Alexey Andreev
2016-11-28 11:38:29 +03:00
parent cf25e17209
commit 3882bf7564
36 changed files with 48 additions and 346 deletions
@@ -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)