The importMethod call (invocation) instruction enables you to send a message to an imported method. For details about importing packages, see Chapter 8, "Using Packages".
Syntax
The syntax of an importMethod call is:
expression := class‑instance.importMethod imported-method-name; expression.type-guard.importMethod imported-method-name;
Description
Use an importMethod call to cause the imported method specified by imported-method-name to be invoked for the instance referred to by the expression.
If the imported method being called takes no parameters, the parentheses on the imported method call are optional.
In cases where a locally defined method has the same name as an exported method, developers in the importing schema can use the importMethod call to specify that it is the imported method that is to be invoked.
When calling an imported method, the following rules apply.
Given a reference to an instance of an imported class and an imported method on that class has the same name as a locally defined superclass method, you must use the importMethod call to invoke the imported method via that reference.
If ref holds a reference to an imported class instance at run time, ref.m1 always invokes the local Object::m1 method because locally defined methods are resolved first.
Consider the following conditions.
A reference, ref, of type Object
An imported class, C
A local subschema copy method, m1, defined on Object
An imported method, m1, defined on C
Under these conditions, to invoke the C::m1 via the ref reference, ref must be type-guarded to C and the importMethod call used as follows.
ref.C.importMethod m1;
The type guard is necessary because the importMethod call is permitted only when the type of the receiver, ref, is an imported class.
When invoking an Object subschema copy method via a reference of type