// replace the method with its retargeted clinit
method = clinitTarget.getMethods().get(0);
}
}
JsNameRef qualifier;
JsExpression unnecessaryQualifier = null;
if (method.isStatic()) {
if (x.getInstance() != null) {
unnecessaryQualifier = (JsExpression) pop(); // instance
}
qualifier = names.get(method).makeRef(x.getSourceInfo());
} else {
if (x.isStaticDispatchOnly()) {
/*
* Dispatch statically (odd case). This happens when a call that must
* be static is targeting an instance method that could not be
* transformed into a static. Super/this constructor calls work this
* way. Have to use a "call" construct.
*/
JsName callName = objectScope.declareName("call");
callName.setObfuscatable(false);
qualifier = callName.makeRef(x.getSourceInfo());
qualifier.setQualifier(names.get(method).makeRef(x.getSourceInfo()));
jsInvocation.getArguments().add(0, (JsExpression) pop()); // instance
} else {
// Dispatch polymorphically (normal case).
qualifier = polymorphicNames.get(method).makeRef(x.getSourceInfo());
qualifier.setQualifier((JsExpression) pop()); // instance
}
}
jsInvocation.setQualifier(qualifier);
push(createCommaExpression(unnecessaryQualifier, jsInvocation));
}