JS: when deciding whether inner class of a local class captures this, don't check for subtyping, since frontend generates strict classes in descriptors. Remove fix for #KT-13583, since it's no more needed. Fix #KT-13792
This commit is contained in:
@@ -704,6 +704,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("enclosingClassFromInnerLocalClass.kt")
|
||||||
|
public void testEnclosingClassFromInnerLocalClass() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/closure/enclosingClassFromInnerLocalClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("enclosingClassFromLocalClass.kt")
|
@TestMetadata("enclosingClassFromLocalClass.kt")
|
||||||
public void testEnclosingClassFromLocalClass() throws Exception {
|
public void testEnclosingClassFromLocalClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/closure/enclosingClassFromLocalClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/closure/enclosingClassFromLocalClass.kt");
|
||||||
|
|||||||
@@ -115,13 +115,8 @@ class UsageTracker(
|
|||||||
// Class which instance we are trying to capture
|
// Class which instance we are trying to capture
|
||||||
val currentClass = descriptor.containingDeclaration as? ClassDescriptor ?: return false
|
val currentClass = descriptor.containingDeclaration as? ClassDescriptor ?: return false
|
||||||
|
|
||||||
// We always capture enclosing class if it's not outer (i.e. we are capturing members of enclosing class to a local class)
|
|
||||||
if (containingClass != currentClass && containingClass.containingDeclaration !is ClassDescriptor) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
for (outerDeclaration in generateSequence(containingClass) { it.containingDeclaration as? ClassDescriptor }) {
|
for (outerDeclaration in generateSequence(containingClass) { it.containingDeclaration as? ClassDescriptor }) {
|
||||||
if (DescriptorUtils.isSubclass(outerDeclaration, currentClass)) return true
|
if (outerDeclaration == currentClass) return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
open class X(private val x: String) {
|
||||||
|
fun foo(): String {
|
||||||
|
class B : X("fail1") {
|
||||||
|
inner class C {
|
||||||
|
fun bar() = x
|
||||||
|
}
|
||||||
|
|
||||||
|
fun baz() = C().bar()
|
||||||
|
}
|
||||||
|
return B().baz()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Y(private val x: String) {
|
||||||
|
fun foo(): String {
|
||||||
|
class B {
|
||||||
|
inner class C : Y("fail2") {
|
||||||
|
fun bar() = x
|
||||||
|
}
|
||||||
|
|
||||||
|
fun baz() = C().bar()
|
||||||
|
}
|
||||||
|
return B().baz()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val x = X("OK").foo()
|
||||||
|
if (x != "OK") return x
|
||||||
|
|
||||||
|
val y = Y("OK").foo()
|
||||||
|
if (y != "OK") return y
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user