CF for new-expression
This commit is contained in:
@@ -472,27 +472,38 @@ public class JetControlFlowProcessor {
|
|||||||
builder.readNode(expression);
|
builder.readNode(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void visitCall(JetCall call) {
|
||||||
public void visitCallExpression(JetCallExpression expression) {
|
for (JetArgument argument : call.getValueArguments()) {
|
||||||
for (JetTypeProjection typeArgument : expression.getTypeArguments()) {
|
|
||||||
value(typeArgument, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (JetArgument argument : expression.getValueArguments()) {
|
|
||||||
JetExpression argumentExpression = argument.getArgumentExpression();
|
JetExpression argumentExpression = argument.getArgumentExpression();
|
||||||
if (argumentExpression != null) {
|
if (argumentExpression != null) {
|
||||||
value(argumentExpression, false, false);
|
value(argumentExpression, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JetExpression functionLiteral : expression.getFunctionLiteralArguments()) {
|
for (JetExpression functionLiteral : call.getFunctionLiteralArguments()) {
|
||||||
value(functionLiteral, false, false);
|
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);
|
value(expression.getCalleeExpression(), false, false);
|
||||||
builder.readNode(expression);
|
builder.readNode(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitNewExpression(JetNewExpression expression) {
|
||||||
|
// TODO : Instantiated class is loaded
|
||||||
|
// TODO : type arguments?
|
||||||
|
visitCall(expression);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitProperty(JetProperty property) {
|
public void visitProperty(JetProperty property) {
|
||||||
JetExpression initializer = property.getInitializer();
|
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
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetCallExpression extends JetExpression {
|
public class JetCallExpression extends JetExpression implements JetCall {
|
||||||
public JetCallExpression(@NotNull ASTNode node) {
|
public JetCallExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@ public class JetCallExpression extends JetExpression {
|
|||||||
return callee;
|
return callee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetArgumentList getValueArgumentList() {
|
public JetArgumentList getValueArgumentList() {
|
||||||
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
||||||
@@ -38,11 +39,13 @@ public class JetCallExpression extends JetExpression {
|
|||||||
return (JetTypeArgumentList) findChildByType(JetNodeTypes.TYPE_ARGUMENT_LIST);
|
return (JetTypeArgumentList) findChildByType(JetNodeTypes.TYPE_ARGUMENT_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetExpression> getFunctionLiteralArguments() {
|
public List<JetExpression> getFunctionLiteralArguments() {
|
||||||
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
|
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetArgument> getValueArguments() {
|
public List<JetArgument> getValueArguments() {
|
||||||
JetArgumentList list = getValueArgumentList();
|
JetArgumentList list = getValueArgumentList();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetNewExpression extends JetExpression {
|
public class JetNewExpression extends JetExpression implements JetCall {
|
||||||
public JetNewExpression(@NotNull ASTNode node) {
|
public JetNewExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
@@ -26,17 +26,20 @@ public class JetNewExpression extends JetExpression {
|
|||||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetArgumentList getArgumentList() {
|
public JetArgumentList getValueArgumentList() {
|
||||||
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
return (JetArgumentList) findChildByType(JetNodeTypes.VALUE_ARGUMENT_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetArgument> getArguments() {
|
public List<JetArgument> getValueArguments() {
|
||||||
JetArgumentList list = getArgumentList();
|
JetArgumentList list = getValueArgumentList();
|
||||||
return list != null ? list.getArguments() : Collections.<JetArgument>emptyList();
|
return list != null ? list.getArguments() : Collections.<JetArgument>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetExpression> getFunctionLiteralArguments() {
|
public List<JetExpression> getFunctionLiteralArguments() {
|
||||||
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
|
return findChildrenByType(JetNodeTypes.FUNCTION_LITERAL);
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ public class JetTypeChecker {
|
|||||||
if (expected.getConstructor().equals(JetStandardClasses.getTuple(0).getTypeConstructor())) {
|
if (expected.getConstructor().equals(JetStandardClasses.getTuple(0).getTypeConstructor())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if (actual.getArguments().isEmpty()) {
|
// if (actual.getValueArguments().isEmpty()) {
|
||||||
// TypeConstructor actualConstructor = actual.getConstructor();
|
// TypeConstructor actualConstructor = actual.getConstructor();
|
||||||
// TypeConstructor constructor = expected.getConstructor();
|
// TypeConstructor constructor = expected.getConstructor();
|
||||||
// Set<TypeConstructor> convertibleTo = getConversionMap().get(actualConstructor);
|
// Set<TypeConstructor> convertibleTo = getConversionMap().get(actualConstructor);
|
||||||
|
|||||||
@@ -940,14 +940,14 @@ public class JetTypeInferrer {
|
|||||||
OverloadDomain constructorsOverloadDomain = semanticServices.getOverloadResolver().getOverloadDomain(constructors);
|
OverloadDomain constructorsOverloadDomain = semanticServices.getOverloadResolver().getOverloadDomain(constructors);
|
||||||
JetType constructorReturnedType = resolveOverloads(
|
JetType constructorReturnedType = resolveOverloads(
|
||||||
scope,
|
scope,
|
||||||
wrapForTracing(constructorsOverloadDomain, referenceExpression, expression.getArgumentList(), false),
|
wrapForTracing(constructorsOverloadDomain, referenceExpression, expression.getValueArgumentList(), false),
|
||||||
Collections.<JetTypeProjection>emptyList(),
|
Collections.<JetTypeProjection>emptyList(),
|
||||||
expression.getArguments(),
|
expression.getValueArguments(),
|
||||||
expression.getFunctionLiteralArguments());
|
expression.getFunctionLiteralArguments());
|
||||||
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
|
if (constructorReturnedType == null && !ErrorUtils.isErrorType(receiverType)) {
|
||||||
trace.recordReferenceResolution(referenceExpression, receiverType.getConstructor().getDeclarationDescriptor());
|
trace.recordReferenceResolution(referenceExpression, receiverType.getConstructor().getDeclarationDescriptor());
|
||||||
// TODO : more helpful message
|
// TODO : more helpful message
|
||||||
JetArgumentList argumentList = expression.getArgumentList();
|
JetArgumentList argumentList = expression.getValueArgumentList();
|
||||||
if (argumentList != null) {
|
if (argumentList != null) {
|
||||||
semanticServices.getErrorHandler().genericError(argumentList.getNode(), "Cannot find an overload for these arguments");
|
semanticServices.getErrorHandler().genericError(argumentList.getNode(), "Cannot find an overload for these arguments");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user