Class ObjectClassInference
What a variable of no particular class - declared Object or Variant - is known to hold, from the code that assigns it: the classes of the objects
it is Set to that are created by name (ObjectCreationFact), its candidate classes.
public static class ObjectClassInference
- Inheritance
-
ObjectClassInference
- Inherited Members
Remarks
A fact for tooling - what a completion list offers after the variable - and for nothing else. It is never a declaration: the variable keeps the declared type it is declared with, a member accessed on it is late-bound and found when it is called (MS-VBAL §5.6.12, §6.1.2.8.1.4), nothing that is or is not true of a candidate class is a compile error, and the runtime never reads it.
The candidates are the classes of every Set assignment of the module that binds to the variable, wherever it is in the module and whichever path it is
on: what the variable may hold, not what it holds at a given point of the code. An object that is not created by a CreateObject call whose class
is known adds none.
Methods
CandidateClassesOf(StaticEvaluationContext, ExpressionNode, ScopeTree, Uri, ModuleNode)
The candidate classes of receiver, when it is the name of a variable of no particular class.
public static ImmutableArray<ObjectCreationFact> CandidateClassesOf(StaticEvaluationContext context, ExpressionNode receiver, ScopeTree tree, Uri moduleUri, ModuleNode module)
Parameters
contextStaticEvaluationContextThe context the receiver is evaluated in.
receiverExpressionNodeThe expression, as it is written where the classes are wanted.
treeScopeTreeThe scope tree of the composed workspace, which says the scope of each assignment.
moduleUriUriThe address of the module.
moduleModuleNodeThe syntax tree of the module the receiver is written in, whose assignments are the ones that say what it holds.
Returns
- ImmutableArray<ObjectCreationFact>
Each class once, in the order the module first assigns an object of it; empty when the receiver is not the name of a variable declared
ObjectorVariant, or nothing says what it holds.
ClassOf(ObjectCreationFact, ISymbolResolver, Uri, Func<string, IReadOnlyList<Symbol>>?)
The class a candidate is, as a type whose members can be listed: the class the project resolves, for a class of the standard library or of a library the project references; the class its library describes, for one of a library it does not reference.
public static VBClassType? ClassOf(ObjectCreationFact candidate, ISymbolResolver resolver, Uri origin, Func<string, IReadOnlyList<Symbol>>? described)
Parameters
candidateObjectCreationFactThe candidate class.
resolverISymbolResolverThe resolver of the composed workspace.
originUriWhere the class is looked up from.
describedFunc<string, IReadOnlyList<Symbol>>The symbols of a library the project does not reference, and of the libraries it depends on (ReadDescribed(ILibrarySource, Uri, string, bool)), by the name of the library; or null when there are no descriptions to read.
Returns
- VBClassType
The class; null when it is not found where the candidate says it is.
Remarks
A class of a library the project does not reference is read from the library's description, apart from the names of the project: it is never a name the code can use, and the workspace is not composed with it.