super statement improved
This commit is contained in:
@@ -6,15 +6,17 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class SuperExpression extends Expression {
|
||||
private Type myType;
|
||||
private Identifier myIdentifier;
|
||||
|
||||
public SuperExpression(Type type) {
|
||||
myType = type;
|
||||
public SuperExpression(Identifier identifier) {
|
||||
myIdentifier = identifier;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toKotlin() {
|
||||
return "super" + "<" + myType.toKotlin() + ">";
|
||||
if (myIdentifier.isEmpty())
|
||||
return "super";
|
||||
return "super" + AT + myIdentifier.toKotlin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiLiteralExpressionImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.j2k.Converter;
|
||||
import org.jetbrains.jet.j2k.ast.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -240,7 +239,8 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
super.visitSuperExpression(expression);
|
||||
myResult = new SuperExpression(typeToNotNullableType(expression.getType()));
|
||||
myResult = new SuperExpression(
|
||||
expression.getQualifier() != null ? new IdentifierImpl(expression.getQualifier().getQualifiedName()): Identifier.EMPTY_IDENTIFIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,6 @@ fun call() : Unit {
|
||||
}
|
||||
open class A : B {
|
||||
override fun call() : Unit {
|
||||
return super<B>.call()
|
||||
return super.call()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Base {
|
||||
void foo();
|
||||
}
|
||||
|
||||
class A extends Base {
|
||||
class C {
|
||||
void test() {
|
||||
A.super.foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace {
|
||||
open class Base {
|
||||
fun foo() : Unit
|
||||
}
|
||||
open class A : Base {
|
||||
open class C {
|
||||
fun test() : Unit {
|
||||
super@A.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
super<Any>.call()
|
||||
super.call()
|
||||
Reference in New Issue
Block a user