private bool VisitTypeName(TypeName typeName, int genericArgumentCount, bool isAttribute) { var classDefn = _symbolTable.LookupType(typeName); if (classDefn != null && classDefn.IsAmbiguous()) { _parser.ReportError(typeName.Extent, nameof(ParserStrings.AmbiguousTypeReference), ParserStrings.AmbiguousTypeReference, typeName.Name, GetModuleQualifiedName(classDefn.ExternalNamespaces[0], typeName.Name), GetModuleQualifiedName(classDefn.ExternalNamespaces[1], typeName.Name)); } else if (classDefn != null && genericArgumentCount == 0) { typeName.SetTypeDefinition(classDefn.Type); } else { Exception e; TypeResolutionState trs = genericArgumentCount > 0 || isAttribute ? new TypeResolutionState(_typeResolutionState, genericArgumentCount, isAttribute) : _typeResolutionState; var type = TypeResolver.ResolveTypeNameWithContext(typeName, out e, null, trs); if (type == null) { if (_symbolTable.GetCurrentTypeDefinitionAst() != null) { // [ordered] is an attribute, but it's looks like a type constraint. if (!typeName.FullName.Equals(LanguagePrimitives.OrderedAttribute, StringComparison.OrdinalIgnoreCase)) { string errorId; string errorMsg; if (isAttribute) { errorId = nameof(ParserStrings.CustomAttributeTypeNotFound); errorMsg = ParserStrings.CustomAttributeTypeNotFound; } else { errorId = nameof(ParserStrings.TypeNotFound); errorMsg = ParserStrings.TypeNotFound; } _parser.ReportError(typeName.Extent, errorId, errorMsg, typeName.Name); } } } else { ((ISupportsTypeCaching)typeName).CachedType = type; return(true); } } return(false); }
private bool VisitTypeName(TypeName typeName, int genericArgumentCount, bool isAttribute) { var classDefn = _symbolTable.LookupType(typeName); if (classDefn != null && classDefn.IsAmbiguous()) { _parser.ReportError(typeName.Extent, () => ParserStrings.AmbiguousTypeReference, typeName.Name, GetModuleQualifiedName(classDefn.ExternalNamespaces[0], typeName.Name), GetModuleQualifiedName(classDefn.ExternalNamespaces[1], typeName.Name)); } else if (classDefn != null && genericArgumentCount == 0) { typeName.SetTypeDefinition(classDefn.Type); } else { Exception e; TypeResolutionState trs = genericArgumentCount > 0 || isAttribute ? new TypeResolutionState(_typeResolutionState, genericArgumentCount, isAttribute) : _typeResolutionState; var type = TypeResolver.ResolveTypeNameWithContext(typeName, out e, null, trs); if (type == null) { if (_symbolTable.GetCurrentTypeDefinitionAst() != null) { // [ordered] is an attribute, but it's looks like a type constraint. if (!typeName.FullName.Equals(LanguagePrimitives.OrderedAttribute, StringComparison.OrdinalIgnoreCase)) { _parser.ReportError(typeName.Extent, isAttribute ? (Expression<Func<string>>)(() => ParserStrings.CustomAttributeTypeNotFound) : () => ParserStrings.TypeNotFound, typeName.Name); } } } else { ((ISupportsTypeCaching)typeName).CachedType = type; return true; } } return false; }