CF for new-expression

This commit is contained in:
Andrey Breslav
2011-04-14 19:31:22 +04:00
parent cf7991378a
commit 9d32723cbf
6 changed files with 54 additions and 17 deletions
@@ -472,27 +472,38 @@ public class JetControlFlowProcessor {
builder.readNode(expression);
}
@Override
public void visitCallExpression(JetCallExpression expression) {
for (JetTypeProjection typeArgument : expression.getTypeArguments()) {
value(typeArgument, false, false);
}
for (JetArgument argument : expression.getValueArguments()) {
private void visitCall(JetCall call) {
for (JetArgument argument : call.getValueArguments()) {
JetExpression argumentExpression = argument.getArgumentExpression();
if (argumentExpression != null) {
value(argumentExpression, false, false);
}
}
for (JetExpression functionLiteral : expression.getFunctionLiteralArguments()) {
for (JetExpression functionLiteral : call.getFunctionLiteralArguments()) {
value(functionLiteral, false, false);
}
}
@Override
public void visitCallExpression(JetCallExpression expression) {
for (JetTypeProjection typeArgument : expression.getTypeArguments()) {
value(typeArgument, false, false);
}
visitCall(expression);
value(expression.getCalleeExpression(), false, false);
builder.readNode(expression);
}
@Override
public void visitNewExpression(JetNewExpression expression) {
// TODO : Instantiated class is loaded
// TODO : type arguments?
visitCall(expression);
}
@Override
public void visitProperty(JetProperty property) {
JetExpression initializer = property.getInitializer();
@@ -0,0 +1,20 @@
package org.jetbrains.jet.lang.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author abreslav
*/
public interface JetCall {
@Nullable
JetArgumentList getValueArgumentList();
@NotNull
List<JetArgument> getValueArguments();
@NotNull
List<JetExpression> getFunctionLiteralArguments();
}
@@ -11,7 +11,7 @@ import java.util.List;
/**
* @author max
*/
public class JetCallExpression extends JetExpression {
public class JetCallExpression extends JetExpression implements JetCall {
public JetCallExpression(@NotNull ASTNode node) {
super(node);
}
@@ -28,6 +28,7 @@ public class JetCallExpression extends JetExpression {
return callee;
}
@Override
@Nullable
public JetArgumentList getValueArgumentList() {
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
@@ -38,11 +39,13 @@ public class JetCallExpression extends JetExpression {
return (JetTypeArgumentList) findChildByType(JetNodeTypes.TYPE_ARGUMENT_LIST);
}
@Override
@NotNull
public List<JetExpression> getFunctionLiteralArguments() {
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
}
@Override
@NotNull
public List<JetArgument> getValueArguments() {
JetArgumentList list = getValueArgumentList();
@@ -11,7 +11,7 @@ import java.util.List;
/**
* @author max
*/
public class JetNewExpression extends JetExpression {
public class JetNewExpression extends JetExpression implements JetCall {
public JetNewExpression(@NotNull ASTNode node) {
super(node);
}
@@ -26,17 +26,20 @@ public class JetNewExpression extends JetExpression {
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
}
@Override
@Nullable
public JetArgumentList getArgumentList() {
public JetArgumentList getValueArgumentList() {
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
}
@Override
@NotNull
public List<JetArgument> getArguments() {
JetArgumentList list = getArgumentList();
public List<JetArgument> getValueArguments() {
JetArgumentList list = getValueArgumentList();
return list != null ? list.getArguments() : Collections.<JetArgument>emptyList();
}
@Override
@NotNull
public List<JetExpression> getFunctionLiteralArguments() {
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
@@ -295,7 +295,7 @@ public class JetTypeChecker {
if (expected.getConstructor().equals(JetStandardClasses.getTuple(0).getTypeConstructor())) {
return true;
}
// if (actual.getArguments().isEmpty()) {
// if (actual.getValueArguments().isEmpty()) {
// TypeConstructor actualConstructor = actual.getConstructor();
// TypeConstructor constructor = expected.getConstructor();
// Set<TypeConstructor> convertibleTo = getConversionMap().get(actualConstructor);
@@ -940,14 +940,14 @@ public class JetTypeInferrer {
OverloadDomain constructorsOverloadDomain = semanticServices.getOverloadResolver().getOverloadDomain(constructors);
JetType constructorReturnedType = resolveOverloads(
scope,
wrapForTracing(constructorsOverloadDomain, referenceExpression, expression.getArgumentList(), false),
wrapForTracing(constructorsOverloadDomain, referenceExpression, expression.getValueArgumentList(), false),
Collections.<JetTypeProjection>emptyList(),
expression.getArguments(),
expression.getValueArguments(),
expression.getFunctionLiteralArguments());
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
trace.recordReferenceResolution(referenceExpression, receiverType.getConstructor().getDeclarationDescriptor());
// TODO : more helpful message
JetArgumentList argumentList = expression.getArgumentList();
JetArgumentList argumentList = expression.getValueArgumentList();
if (argumentList != null) {
semanticServices.getErrorHandler().genericError(argumentList.getNode(), "Cannot find an overload for these arguments");
}