KT-2752: refactor NameSuggestion, change rules for determining name stability and applying mangling
This commit is contained in:
@@ -8,7 +8,7 @@ package foo
|
||||
// CHECK_HAS_INLINE_METADATA: apply_hiyix$
|
||||
// CHECK_HAS_INLINE_METADATA: applyL_hiyix$
|
||||
// CHECK_HAS_INLINE_METADATA: applyM_hiyix$
|
||||
// CHECK_HAS_NO_INLINE_METADATA: applyN_0
|
||||
// CHECK_HAS_NO_INLINE_METADATA: applyN_hiyix$
|
||||
// CHECK_HAS_NO_INLINE_METADATA: applyO_hiyix$
|
||||
|
||||
inline
|
||||
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
// MODULE: lib1
|
||||
// FILE: lib1.kt
|
||||
package lib1
|
||||
|
||||
interface A {
|
||||
private fun foo() = "A.foo"
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
// MODULE: lib2
|
||||
// FILE: lib2.kt
|
||||
package lib2
|
||||
|
||||
interface B {
|
||||
private fun foo() = "B.foo"
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
// MODULE: main(lib1,lib2)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib1.A
|
||||
+24
-2
@@ -1,3 +1,25 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
private val x = 23
|
||||
|
||||
fun foo() = x
|
||||
}
|
||||
|
||||
// MODULE: lib-old
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
fun foo() = 12
|
||||
}
|
||||
|
||||
inline fun check() = true
|
||||
|
||||
// MODULE: main(lib-old)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.A
|
||||
@@ -14,10 +36,10 @@ class B : A() {
|
||||
// it won't report false positives eventually. So be patient and just update this test whenever you changed
|
||||
// algorithm of assigning unique identifiers.
|
||||
// Please, check that A.x and B.x have different JS names.
|
||||
private fun checkJsNames(o: dynamic): Boolean = "x_i8qwny\$_0" in o && "x_dqqnpp\$_0" in o
|
||||
private fun checkJsNames(o: dynamic): Boolean = "x_i8qwny\$_0" in o && "x_0" in o
|
||||
|
||||
fun box(): String {
|
||||
if (!check()) return "check failed: did not compile agains old library"
|
||||
if (!check()) return "check failed: did not compile against old library"
|
||||
|
||||
val a = A()
|
||||
if (a.foo() != 23) return "fail1: ${a.foo()}"
|
||||
@@ -14,11 +14,9 @@ internal open class A(val a: Int) {
|
||||
internal class B(val b: Int) : A(b / 2) {
|
||||
override fun foo(i: Int): String = "B.foo($i: Int)"
|
||||
|
||||
fun boo(): String = "B.boo()"
|
||||
fun boo(i: String): String = "B.boo($i: String)"
|
||||
|
||||
fun bar(i: String): String = "B.bar($i: String)"
|
||||
fun bar(): String = "B.bar()"
|
||||
override fun baz(i: Int): String = "B.baz($i: Int)"
|
||||
fun bar(d: Double): String = "B.bar($d: Double)"
|
||||
}
|
||||
@@ -33,12 +31,10 @@ fun box(): String {
|
||||
if (b.foo(4) != "B.foo(4: Int)") return "b.foo(4) != \"B.foo(4: Int)\", it: ${b.foo(4)}"
|
||||
|
||||
if (b.boo(434) != "A.boo(434)") return "b.boo(434) != \"A.boo(434)\", it: ${b.boo(434)}"
|
||||
if (b.boo() != "B.boo()") return "b.boo() != \"B.boo()\", it: ${b.boo()}"
|
||||
if (b.boo("qlfj") != "B.boo(qlfj: String)") return "b.boo(\"qlfj\") != \"B.boo(qlfj: String)\", it: ${b.boo("qlfj")}"
|
||||
|
||||
if (b.bar("apl") != "B.bar(apl: String)") return "b.bar(\"apl\") != \"B.bar(apl: String)\", it: ${b.bar("apl")}"
|
||||
if (b.baz(34) != "B.baz(34: Int)") return "b.baz(34) != \"B.baz(34: Int)\", it: ${b.baz(34)}"
|
||||
if (b.bar() != "B.bar()") return "b.bar() != \"B.bar()\", it: ${b.bar()}"
|
||||
if (b.bar(2.213) != "B.bar(2.213: Double)") return "b.bar(2.213) != \"B.bar(2.213: Double)\", it: ${b.bar(2.213)}"
|
||||
|
||||
val a: A = b
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
function createA() {
|
||||
function ADerived() {
|
||||
}
|
||||
ADerived.prototype = Object.create(JS_TESTS.foo.A.prototype);
|
||||
ADerived.prototype.foo_za3lpa$ = function(n) {
|
||||
return 24;
|
||||
};
|
||||
return new ADerived();
|
||||
}
|
||||
|
||||
function createB() {
|
||||
function BDerived() {
|
||||
}
|
||||
BDerived.prototype = Object.create(JS_TESTS.foo.B.prototype);
|
||||
BDerived.prototype.bar_za3lpa$ = function(n) {
|
||||
return this.foo_za3lpa$(n);
|
||||
};
|
||||
return new BDerived();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package foo
|
||||
|
||||
open class A {
|
||||
open protected fun foo(n: Int) = 23
|
||||
|
||||
fun bar(n: Int) = foo(n) + 100
|
||||
}
|
||||
|
||||
open class B {
|
||||
protected fun foo(n: Int) = 42
|
||||
|
||||
open fun bar(n: Int) = 142
|
||||
}
|
||||
|
||||
@native fun createA(): A
|
||||
|
||||
@native fun createB(): B
|
||||
|
||||
fun box(): String {
|
||||
val a = createA()
|
||||
if (a.bar(0) != 124) return "fail1: ${a.bar(0)}"
|
||||
|
||||
val b = createB()
|
||||
if (b.bar(0) != 42) return "fail2: ${b.bar(0)}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,5 +3,5 @@ function A(v) {
|
||||
}
|
||||
|
||||
function nativeBox(b) {
|
||||
return b.bar_0(new A("foo"), function(i, s) { return "" + this.v + s + i })
|
||||
return b.bar_asnz92$(new A("foo"), function(i, s) { return "" + this.v + s + i })
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ fun box(): String {
|
||||
|
||||
val b: dynamic = object {val bar = ""}
|
||||
assertEquals(b.foo, undefined)
|
||||
assertNotEquals(b.bar_0, undefined)
|
||||
assertNotEquals(b.bar, undefined)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -38,8 +38,8 @@ fun box(): String {
|
||||
assertEquals(listOf(), getOwnPropertyNames(emptyObjectExpr))
|
||||
assertEquals(listOf(), keys(emptyObjectExpr))
|
||||
|
||||
assertEquals(listOf("foo_0", "bar_0"), getOwnPropertyNames(someObjectExpr))
|
||||
assertEquals(listOf("foo_0", "bar_0"), keys(someObjectExpr))
|
||||
assertEquals(listOf("foo", "bar"), getOwnPropertyNames(someObjectExpr))
|
||||
assertEquals(listOf("foo", "bar"), keys(someObjectExpr))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
lib1->
|
||||
lib2->
|
||||
main->lib1,lib2
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package lib1
|
||||
|
||||
interface A {
|
||||
private fun foo() = "A.foo"
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package lib2
|
||||
|
||||
interface B {
|
||||
private fun foo() = "B.foo"
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
lib->
|
||||
lib-old->
|
||||
main->lib-old
|
||||
@@ -1,7 +0,0 @@
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
fun foo() = 12
|
||||
}
|
||||
|
||||
inline fun check() = true
|
||||
@@ -1,7 +0,0 @@
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
private val x = 23
|
||||
|
||||
fun foo() = x
|
||||
}
|
||||
Reference in New Issue
Block a user