added generic params to method call expression
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package org.jetbrains.jet.j2k.ast;
|
package org.jetbrains.jet.j2k.ast;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.j2k.util.AstUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ignatov
|
* @author ignatov
|
||||||
@@ -9,11 +12,13 @@ public class MethodCallExpression extends Expression {
|
|||||||
private final Expression myMethodCall;
|
private final Expression myMethodCall;
|
||||||
private final Element myParamList;
|
private final Element myParamList;
|
||||||
private final boolean myIsResultNullable;
|
private final boolean myIsResultNullable;
|
||||||
|
private List<Type> myTypeParameters;
|
||||||
|
|
||||||
public MethodCallExpression(Expression methodCall, Element paramList, boolean nullable) {
|
public MethodCallExpression(Expression methodCall, Element paramList, boolean nullable, List<Type> typeParameters) {
|
||||||
myMethodCall = methodCall;
|
myMethodCall = methodCall;
|
||||||
myParamList = paramList;
|
myParamList = paramList;
|
||||||
myIsResultNullable = nullable;
|
myIsResultNullable = nullable;
|
||||||
|
myTypeParameters = typeParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -24,6 +29,7 @@ public class MethodCallExpression extends Expression {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String toKotlin() {
|
public String toKotlin() {
|
||||||
return myMethodCall.toKotlin() + "(" + myParamList.toKotlin() + ")";
|
String typeParamsToKotlin = myTypeParameters.size() > 0 ? "<" + AstUtil.joinNodes(myTypeParameters, COMMA_WITH_SPACE) + ">" : EMPTY;
|
||||||
|
return myMethodCall.toKotlin() + typeParamsToKotlin + "(" + myParamList.toKotlin() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,8 @@ public class ExpressionVisitor extends StatementVisitor {
|
|||||||
new MethodCallExpression(
|
new MethodCallExpression(
|
||||||
expressionToExpression(expression.getMethodExpression()),
|
expressionToExpression(expression.getMethodExpression()),
|
||||||
elementToElement(expression.getArgumentList()),
|
elementToElement(expression.getArgumentList()),
|
||||||
typeToType(expression.getType()).isNullable()
|
typeToType(expression.getType()).isNullable(),
|
||||||
|
typesToTypeList(expression.getTypeArguments())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
|||||||
if (constructor != null && !isConstructorPrimary(constructor)) {
|
if (constructor != null && !isConstructorPrimary(constructor)) {
|
||||||
myResult = new CallChainExpression(
|
myResult = new CallChainExpression(
|
||||||
new IdentifierImpl(constructor.getName(), false),
|
new IdentifierImpl(constructor.getName(), false),
|
||||||
new MethodCallExpression(new IdentifierImpl("init"), elementToElement(expression.getArgumentList()), false));
|
new MethodCallExpression(new IdentifierImpl("init"), elementToElement(expression.getArgumentList()), false, typesToTypeList(expression.getTypeArguments())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package demo;
|
||||||
|
|
||||||
|
class Map {
|
||||||
|
<K, V> void put(K k, V v) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class U {
|
||||||
|
void test() {
|
||||||
|
Map m = new Map();
|
||||||
|
m.<String, int>put("10", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace demo {
|
||||||
|
open class Map() {
|
||||||
|
open fun put<K, V>(k : K?, v : V?) : Unit {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
open class U() {
|
||||||
|
open fun test() : Unit {
|
||||||
|
var m : Map? = Map()
|
||||||
|
m?.put<String?, Int>("10", 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user