KT-2822 Can't make a super call from an object literal

#KT-2822 Fixed
This commit is contained in:
Alexander Udalov
2012-09-26 21:53:35 +04:00
parent 66359894ee
commit acf8702ccf
4 changed files with 17 additions and 3 deletions
@@ -1730,8 +1730,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (enclosed != context.getThisDescriptor()) {
CodegenContext c = context;
//noinspection ConstantConditions
while (!(c instanceof ClassContext) ||
!DescriptorUtils.isSubclass(c.getThisDescriptor(), enclosed)) {
while (true) {
if ((c instanceof ClassContext || c instanceof AnonymousClassContext) &&
DescriptorUtils.isSubclass(c.getThisDescriptor(), enclosed)) {
break;
}
c = c.getParentContext();
assert c != null;
}
@@ -25,7 +25,7 @@ import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
/**
* @author alex.tkachman
*/
class AnonymousClassContext extends CodegenContext {
public class AnonymousClassContext extends CodegenContext {
public AnonymousClassContext(
JetTypeMapper typeMapper,
ClassDescriptor contextDescriptor,
@@ -0,0 +1,7 @@
open class A {
fun foo() = "OK"
}
fun box() = object : A() {
fun bar() = super<A>.foo()
}.bar()
@@ -115,4 +115,8 @@ public class ObjectGenTest extends CodegenTestCase {
public void testKt2663_2() {
blackBoxFile("regressions/kt2663_2.kt");
}
public void testKt2822() {
blackBoxFile("regressions/kt2822.kt");
}
}