public static (DeclaredSymbol?, ObjectType?) ExtractResourceOrModuleSymbolAndBodyObj(SemanticModel model, VariableAccessSyntax syntax) { var baseSymbol = model.GetSymbolInfo(syntax); switch (baseSymbol) { case ResourceSymbol: case ModuleSymbol: var declaredSymbol = (DeclaredSymbol)baseSymbol; var unwrapped = TypeAssignmentVisitor.UnwrapType(declaredSymbol.Type); return(declaredSymbol, unwrapped is ObjectType ? (ObjectType)unwrapped : null); } return(null, null); }
public override void VisitInstanceFunctionCallSyntax(InstanceFunctionCallSyntax syntax) { if (this.model.Binder.GetParent(syntax) is DecoratorSyntax) { return; } var baseType = this.model.TypeManager.GetTypeInfo(syntax.BaseExpression); if (TypeAssignmentVisitor.UnwrapType(baseType) is not ObjectType objectType) { return; } var symbol = SymbolValidator.ResolveObjectQualifiedFunctionWithoutValidatingFlags( objectType.MethodResolver.TryGetSymbol(syntax.Name), syntax.Name, objectType); if (symbol is not FunctionSymbol functionSymbol) { return; } var currentDeployTimeConstantScopeSyntax = this.deployTimeConstantScopeSyntax; if (functionSymbol.FunctionFlags.HasFlag(FunctionFlags.RequiresInlining)) { this.deployTimeConstantScopeSyntax = syntax; } base.VisitInstanceFunctionCallSyntax(syntax); if (this.errorSyntax is not null) { this.AppendError(); } this.deployTimeConstantScopeSyntax = currentDeployTimeConstantScopeSyntax; }