Resolution order comes into play as soon as unqualified identifiers are involved. These are expressions in the form of foo(), foo = 1 and foo.field. The last one in particular includes module paths such as haxe.ds.StringMap, where haxe is an unqualified identifier.
We describe the resolution order algorithm here, which depends on the following state:
untyped or not.Figure: Resolution order of identifier `i'
Given an identifier i, the algorithm is as follows:
true, false, this, super or null, resolve to the matching constant and halt.i is accessible, resolve to it and halt.i, resolve to it and halt.i, resolve to it and halt.i is declared on an imported enum, resolve to it and halt.i is explicitly imported, resolve to it and halt.i starts with a lower-case character, go to 11.i is available, resolve to it and halt.i equals __this__, resolve to the this constant and halt.i, resolve to it and halt.For step 10, it is also necessary to define the resolution order of types:
i is imported (directly or as part of a module), resolve to it and halt.i with a type named i, resolve to it and halt.i is available at top-level, resolve to it and halt.For step 1 of this algorithm, as well as steps 5 and 7 of the previous one, the order of import resolution is important:
import.hx files affect a module, the ones in child directories have priority over the ones in parent directories.