diff --git a/src/org/rascalmpl/interpreter/matching/TypedVariablePattern.java b/src/org/rascalmpl/interpreter/matching/TypedVariablePattern.java index ef64cf610df..e94a28eddaa 100644 --- a/src/org/rascalmpl/interpreter/matching/TypedVariablePattern.java +++ b/src/org/rascalmpl/interpreter/matching/TypedVariablePattern.java @@ -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<>()); + dynMatchType = AbstractFunction.renameType(dynMatchType, new HashMap<>(), ctx.getCurrentAST().getLocation()); } if (!declaredType.match(dynMatchType, dynBindings)) { @@ -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<>()); + dynType = AbstractFunction.renameType(dynType, new HashMap<>(), ctx.getCurrentAST().getLocation()); } if (!dynType.isSubtypeOf(declaredType.instantiate(ctx.getCurrentEnvt().getDynamicTypeBindings()))) { diff --git a/src/org/rascalmpl/interpreter/result/AbstractFunction.java b/src/org/rascalmpl/interpreter/result/AbstractFunction.java index 7a453732d21..a0a29e38fc2 100644 --- a/src/org/rascalmpl/interpreter/result/AbstractFunction.java +++ b/src/org/rascalmpl/interpreter/result/AbstractFunction.java @@ -24,8 +24,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.UUID; - import org.rascalmpl.ast.AbstractAST; import org.rascalmpl.ast.Expression; import org.rascalmpl.ast.FunctionDeclaration; @@ -45,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; @@ -347,8 +346,9 @@ 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); + actualStaticTypes = renameType(actualStaticTypes, renamings, env.getLocation()); } + Map staticBindings = new HashMap(); @@ -394,13 +394,13 @@ protected static Type unrenameType(Map renamings, Type resultType) { return resultType; } - public static Type renameType(Type actualTypes, Map renamings) { + public static Type renameType(Type actualTypes, Map renamings, ISourceLocation uniquePrefix) { actualTypes.match(TypeFactory.getInstance().voidType(), renamings); // rename all the bound type parameters for (Entry entry : renamings.entrySet()) { Type key = entry.getKey(); - renamings.put(key, TypeFactory.getInstance().parameterType(key.getName() + ":" + UUID.randomUUID().toString(), key.getBound())); + renamings.put(key, TypeFactory.getInstance().parameterType(key.getName() + ":" + uniquePrefix, key.getBound())); } actualTypes = actualTypes.instantiate(renamings); return actualTypes; diff --git a/src/org/rascalmpl/interpreter/result/NamedFunction.java b/src/org/rascalmpl/interpreter/result/NamedFunction.java index d6f48776587..4323f410129 100644 --- a/src/org/rascalmpl/interpreter/result/NamedFunction.java +++ b/src/org/rascalmpl/interpreter/result/NamedFunction.java @@ -164,7 +164,7 @@ protected void checkReturnTypeIsNotVoid(List formals, IValue[] actua Map bindings = new HashMap<>(); for (int i = 0; i < actuals.length; i++) { - formals.get(i).typeOf(declarationEnvironment, getEval(), false).match(renameType(actuals[i].getType(), renamings), 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()) { diff --git a/src/org/rascalmpl/interpreter/result/RascalFunction.java b/src/org/rascalmpl/interpreter/result/RascalFunction.java index 390142ec8e7..7eabbc774e7 100644 --- a/src/org/rascalmpl/interpreter/result/RascalFunction.java +++ b/src/org/rascalmpl/interpreter/result/RascalFunction.java @@ -128,7 +128,6 @@ private List cloneBody() { return getAst().clone(body); } - private String computeIndexedLabel(int pos, AbstractAST ast) { return ast.accept(new NullASTVisitor() { @Override diff --git a/src/org/rascalmpl/values/RascalFunctionValueFactory.java b/src/org/rascalmpl/values/RascalFunctionValueFactory.java index 5f462421c07..9e496b66c46 100644 --- a/src/org/rascalmpl/values/RascalFunctionValueFactory.java +++ b/src/org/rascalmpl/values/RascalFunctionValueFactory.java @@ -304,6 +304,7 @@ public IFunction loadParsers(ISourceLocation saveLocation, IBool allowAmbiguity, tf.tupleType(rtf.reifiedType(parameterType), tf.valueType(), tf.sourceLocationType()), tf.tupleEmpty()); + @SuppressWarnings({"unchecked"}) final Class> parser = (Class>) ctx.getEvaluator() .__getJavaBridge().loadClass(URIResolverRegistry.getInstance().getInputStream(saveLocation)); @@ -329,7 +330,7 @@ public IFunction loadParser(IValue reifiedGrammar, ISourceLocation saveLocation, tf.tupleType(tf.valueType(), tf.sourceLocationType()), tf.tupleEmpty()); - + @SuppressWarnings({"unchecked"}) final Class> parser = (Class>) ctx.getEvaluator() .__getJavaBridge().loadClass(URIResolverRegistry.getInstance().getInputStream(saveLocation));