|
86 | 86 | implied_imports []string // imports that the user's code uses but omitted to import explicitly, used by `vfmt` |
87 | 87 | imported_symbols map[string]string |
88 | 88 | imported_symbols_used map[string]bool |
| 89 | + imported_symbols_trie token.KeywordsMatcherTrie |
89 | 90 | is_amp bool // for generating the right code for `&Foo{}` |
90 | 91 | returns bool |
91 | 92 | is_stmt_ident bool // true while the beginning of a statement is an ident/selector |
@@ -343,6 +344,7 @@ pub fn (mut p Parser) parse() &ast.File { |
343 | 344 | mod: module_decl |
344 | 345 | imports: p.ast_imports |
345 | 346 | imported_symbols: p.imported_symbols |
| 347 | + imported_symbols_trie: token.new_keywords_matcher_from_array_trie(p.imported_symbols.keys()) |
346 | 348 | imported_symbols_used: p.imported_symbols_used |
347 | 349 | auto_imports: p.auto_imports |
348 | 350 | used_imports: p.used_imports |
@@ -592,8 +594,7 @@ fn (mut p Parser) check_name() string { |
592 | 594 | name := p.tok.lit |
593 | 595 | if p.tok.kind != .name && p.peek_tok.kind == .dot && name in p.imports { |
594 | 596 | p.register_used_import(name) |
595 | | - } else if p.tok.kind == .name && p.peek_tok.kind == .dot && name in p.imported_symbols |
596 | | - && !p.imported_symbols_used[name] { |
| 597 | + } else if p.tok.kind == .name && p.is_imported_symbol(name) && !p.imported_symbols_used[name] { |
597 | 598 | // symbols like Enum.field_name |
598 | 599 | p.register_used_import_for_symbol_name(p.imported_symbols[name]) |
599 | 600 | } |
@@ -2698,7 +2699,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl { |
2698 | 2699 | return ast.FnTypeDecl{} |
2699 | 2700 | } |
2700 | 2701 | } |
2701 | | - if name in p.imported_symbols { |
| 2702 | + if p.is_imported_symbol(name) { |
2702 | 2703 | p.error_with_pos('cannot register alias `${name}`, this type was already imported', |
2703 | 2704 | end_pos) |
2704 | 2705 | return ast.AliasTypeDecl{} |
|
0 commit comments