Type Resolution and System Namespace for Types
Because the type system must resolve user-defined types defined locally or in other classes, the Apex parser evaluates types as follows:
- For a type reference
TypeN, the parser first looks up that type as a scalar type. - If
TypeNis not found, the parser looks up locally defined types. - If
TypeNstill is not found, the parser looks up a class of that name. - If
TypeNstill is not found, the parser looks up system types such as sObjects.
For the type T1.T2 this could mean an inner type T2 in a top-level class T1, or it could mean a top-level class T2 in the namespace T1 (in that order of precedence).