OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dart2js.resolution.common; | 5 library dart2js.resolution.common; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 Scope get scope; | 49 Scope get scope; |
50 | 50 |
51 MappingVisitor(Resolution resolution, this.registry) | 51 MappingVisitor(Resolution resolution, this.registry) |
52 : typeResolver = new TypeResolver(resolution), | 52 : typeResolver = new TypeResolver(resolution), |
53 super(resolution); | 53 super(resolution); |
54 | 54 |
55 AsyncMarker get currentAsyncMarker => AsyncMarker.SYNC; | 55 AsyncMarker get currentAsyncMarker => AsyncMarker.SYNC; |
56 | 56 |
57 /// Add [element] to the current scope and check for duplicate definitions. | 57 /// Add [element] to the current scope and check for duplicate definitions. |
58 void addToScope(Element element) { | 58 void addToScope(Element element) { |
59 if (element is FormalElement && element.isUnnamed) { | |
60 // No duplicate names possible. | |
61 return; | |
62 } | |
63 Element existing = scope.add(element); | 59 Element existing = scope.add(element); |
64 if (existing != element) { | 60 if (existing != element) { |
65 reportDuplicateDefinition(element.name, element, existing); | 61 reportDuplicateDefinition(element.name, element, existing); |
66 } | 62 } |
67 } | 63 } |
68 | 64 |
69 void checkLocalDefinitionName(Node node, Element element) { | 65 void checkLocalDefinitionName(Node node, Element element) { |
70 if (currentAsyncMarker != AsyncMarker.SYNC) { | 66 if (currentAsyncMarker != AsyncMarker.SYNC) { |
71 if (element.name == 'yield' || | 67 if (element.name == 'yield' || |
72 element.name == 'async' || | 68 element.name == 'async' || |
(...skipping 19 matching lines...) Expand all Loading... |
92 String name, Spannable definition, Spannable existing) { | 88 String name, Spannable definition, Spannable existing) { |
93 reporter.reportError( | 89 reporter.reportError( |
94 reporter.createMessage( | 90 reporter.createMessage( |
95 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), | 91 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), |
96 <DiagnosticMessage>[ | 92 <DiagnosticMessage>[ |
97 reporter.createMessage( | 93 reporter.createMessage( |
98 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), | 94 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), |
99 ]); | 95 ]); |
100 } | 96 } |
101 } | 97 } |
OLD | NEW |