Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.facebook.presto.sql.tree.SymbolReference;
import com.google.common.primitives.Ints;

import javax.annotation.Nullable;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -88,7 +90,7 @@ public VariableReferenceExpression newVariable(String nameHint, Type type, Strin
}

@Override
public VariableReferenceExpression newVariable(Optional<SourceLocation> sourceLocation, String nameHint, Type type, String suffix)
public VariableReferenceExpression newVariable(Optional<SourceLocation> sourceLocation, String nameHint, Type type, @Nullable String suffix)
{
requireNonNull(nameHint, "name is null");
requireNonNull(type, "type is null");
Expand Down Expand Up @@ -116,11 +118,10 @@ public VariableReferenceExpression newVariable(Optional<SourceLocation> sourceLo
unique = DISALLOWED_CHAR_PATTERN.matcher(unique).replaceAll("_");

String attempt = unique;
while (variables.containsKey(attempt)) {
while (variables.putIfAbsent(attempt, type) != null) {
attempt = unique + "_" + nextId();
}

variables.put(attempt, type);
return new VariableReferenceExpression(sourceLocation, attempt, type);
}

Expand Down