oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.4k stars 1.64k forks source link

[TruffleDSL] Use of generic types in node constructor leads to broken createNode signature #1485

Open smarr opened 5 years ago

smarr commented 5 years ago

Let's take the following example:

@NodeChild(value = "val", type = ExprNode.class)
@Primitive(primitive = "abs", selector = "abs")
@GenerateNodeFactory
public abstract class AbsNode extends ExprNode {

  public AbsNode(final Map<String, String> myMap) {}

  public abstract int executeEvaluated(int val);

  @Specialization
  public int abs(final int val) {
    return Math.abs(val);
  }
}

This currently compiles to:

    public AbsNode createNode(Object... arguments) {
        if (arguments.length == 2 && (arguments[0] == null || arguments[0] instanceof Map<??>) && (arguments[1] == null || arguments[1] instanceof ExprNode)) {
            return create((Map<String, String>) arguments[0], (ExprNode) arguments[1]);
        } else {
            throw new IllegalArgumentException("Invalid create signature.");
        }
    }

See the missing , between the ?? for instanceof Map<??>.

In earlier versions this used to work.

@chumer looks like a regression, worked on my old May 2018 Truffle :)

boris-spas commented 4 years ago

Tracked internally as Issue GR-20920.