Skip to content

Commit

Permalink
fixes #1293
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Dec 12, 2019
1 parent 679dfdb commit 0631bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/org/rascalmpl/interpreter/result/AbstractFunction.java
Expand Up @@ -173,13 +173,13 @@ public Environment getEnv() {
return declarationEnvironment;
}

public boolean match(Type actuals) {
public boolean mayMatch(Type actuals) {
if (actuals.isSubtypeOf(getFormals())) {
return true;
}

if (hasVarArgs) {
return matchVarArgsFunction(actuals);
return mayMatchVarArgsFunction(actuals);
}

return false;
Expand Down Expand Up @@ -210,7 +210,7 @@ public Result<IValue> call(IRascalMonitor monitor, Type[] argTypes, IValue[] ar
}
}

private boolean matchVarArgsFunction(Type actuals) {
private boolean mayMatchVarArgsFunction(Type actuals) {
int arity = getFormals().getArity();
int i;

Expand Down
10 changes: 6 additions & 4 deletions src/org/rascalmpl/semantics/dynamic/Expression.java
Expand Up @@ -382,11 +382,12 @@ private java.util.Map<String, IMatchingResult> visitKeywordArguments(IEvaluatorC
return result;
}

private Type computeConstructorType(IEvaluatorContext eval,
org.rascalmpl.ast.Expression nameExpr) {
private Type computeConstructorType(IEvaluatorContext eval, org.rascalmpl.ast.Expression nameExpr) {
java.util.List<AbstractFunction> functions = new LinkedList<AbstractFunction>();

String cons = Names.consName(nameExpr.getQualifiedName());
Type adt = eval.getCurrentEnvt().lookupAbstractDataType(Names.moduleName(nameExpr.getQualifiedName()));

if (adt != null) {
eval.getCurrentEnvt().getAllFunctions(adt, cons, functions);
}
Expand All @@ -400,16 +401,17 @@ private Type computeConstructorType(IEvaluatorContext eval,
}

Type signature = getArgumentTypes(eval);
Type constructorType = TF.nodeType();
Type constructorType = adt != null ? adt : TF.nodeType();

for (AbstractFunction candidate : functions) {
if (candidate.getReturnType().isAbstractData() && !candidate.getReturnType().isBottom() && candidate.match(signature)) {
if (candidate.getReturnType().isAbstractData() && !candidate.getReturnType().isBottom() && candidate.mayMatch(signature)) {
Type decl = eval.getCurrentEnvt().getConstructor(candidate.getReturnType(), cons, signature);
if (decl != null) {
constructorType = decl;
}
}
}

return constructorType;
}

Expand Down

0 comments on commit 0631bb0

Please sign in to comment.