Skip to content

Commit

Permalink
more specific ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Oct 13, 2023
1 parent eb2c376 commit 976b864
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public boolean next() {

if (dynMatchType.isOpen()) {
// type parameter hygiene required (consider self-application of a function like `&T id(&T v) = v`)
dynMatchType = AbstractFunction.renameType(dynMatchType, new HashMap<>(), Integer.toString(ctx.getCurrentAST().getLocation().getOffset()));
dynMatchType = AbstractFunction.renameType(dynMatchType, new HashMap<>(), ctx.getCurrentAST().getLocation());
}

if (!declaredType.match(dynMatchType, dynBindings)) {
Expand All @@ -134,7 +134,7 @@ public boolean next() {
Type dynType = subject.getValue().getType();
if (dynType.isOpen()) {
// type parameter hygiene required (consider self-application of a function like `&T id(&T v) = v`)
dynType = AbstractFunction.renameType(dynType, new HashMap<>(), Integer.toString(ctx.getCurrentAST().getLocation().getOffset()));
dynType = AbstractFunction.renameType(dynType, new HashMap<>(), ctx.getCurrentAST().getLocation());
}

if (!dynType.isSubtypeOf(declaredType.instantiate(ctx.getCurrentEnvt().getDynamicTypeBindings()))) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/rascalmpl/interpreter/result/AbstractFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.IExternalValue;
import io.usethesource.vallang.IListWriter;
import io.usethesource.vallang.ISourceLocation;
import io.usethesource.vallang.IValue;
import io.usethesource.vallang.IValueFactory;
import io.usethesource.vallang.IWithKeywordParameters;
Expand Down Expand Up @@ -345,7 +346,7 @@ protected Type bindTypeParameters(Type actualStaticTypes, IValue[] actuals, Type
if (actualStaticTypes.isOpen()) {
// we have to make the environment hygenic now, because the caller scope
// may have the same type variable names as the current scope
actualStaticTypes = renameType(actualStaticTypes, renamings, Integer.toString(env.getLocation().getOffset()));
actualStaticTypes = renameType(actualStaticTypes, renamings, env.getLocation());
}


Expand Down Expand Up @@ -393,7 +394,7 @@ protected static Type unrenameType(Map<Type, Type> renamings, Type resultType) {
return resultType;
}

public static Type renameType(Type actualTypes, Map<Type, Type> renamings, String uniquePrefix) {
public static Type renameType(Type actualTypes, Map<Type, Type> renamings, ISourceLocation uniquePrefix) {
actualTypes.match(TypeFactory.getInstance().voidType(), renamings);

// rename all the bound type parameters
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/interpreter/result/NamedFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected void checkReturnTypeIsNotVoid(List<Expression> formals, IValue[] actua
Map<Type, Type> bindings = new HashMap<>();

for (int i = 0; i < actuals.length; i++) {
formals.get(i).typeOf(declarationEnvironment, getEval(), false).match(renameType(actuals[i].getType(), renamings, Integer.toString(ctx.getCurrentAST().getLocation().getOffset())), bindings);
formals.get(i).typeOf(declarationEnvironment, getEval(), false).match(renameType(actuals[i].getType(), renamings, ctx.getCurrentAST().getLocation()), bindings);
}

if (!getReturnType().isBottom() && getReturnType().instantiate(bindings).isBottom()) {
Expand Down

0 comments on commit 976b864

Please sign in to comment.