ModelDriven / Alf-Reference-Implementation

Open-source implementation of the Action Language for fUML (Alf) specification.
30 stars 2 forks source link

Implicit instantiation of an activity template with type "any" causes exception #79

Closed seidewitz closed 5 years ago

seidewitz commented 5 years ago

It is not normally possible to instantiate a template explicitly using any (i.e, "no type") as the argument for a type parameter. However, if an activity template is implicitly instantiated in an invocation, then it is possible for the implicit template parameter argument to be any. For examaple,

activity A<T>(in x: T[*]) {  }

activity Test() {
    a = null;
    A(a);
}

causes the exception:

Exception in thread "main" java.lang.NullPointerException
    at org.modeldriven.alf.syntax.expressions.impl.QualifiedNameImpl.updateForBinding(QualifiedNameImpl.java:872)
seidewitz commented 5 years ago

The problem is that QualifiedName.updateForBinding checks if a template argument is null, but it doesn't check whether the argument is any, which is representated by ElementReferenceImpl.any rather than null. This causes the NPR when an attempt is made to get the qualified name of the template argument.

seidewitz commented 5 years ago

Resolved in 1.1.0g.