| 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 } |
| 59 Element existing = scope.add(element); | 63 Element existing = scope.add(element); |
| 60 if (existing != element) { | 64 if (existing != element) { |
| 61 reportDuplicateDefinition(element.name, element, existing); | 65 reportDuplicateDefinition(element.name, element, existing); |
| 62 } | 66 } |
| 63 } | 67 } |
| 64 | 68 |
| 65 void checkLocalDefinitionName(Node node, Element element) { | 69 void checkLocalDefinitionName(Node node, Element element) { |
| 66 if (currentAsyncMarker != AsyncMarker.SYNC) { | 70 if (currentAsyncMarker != AsyncMarker.SYNC) { |
| 67 if (element.name == 'yield' || | 71 if (element.name == 'yield' || |
| 68 element.name == 'async' || | 72 element.name == 'async' || |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 String name, Spannable definition, Spannable existing) { | 92 String name, Spannable definition, Spannable existing) { |
| 89 reporter.reportError( | 93 reporter.reportError( |
| 90 reporter.createMessage( | 94 reporter.createMessage( |
| 91 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), | 95 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), |
| 92 <DiagnosticMessage>[ | 96 <DiagnosticMessage>[ |
| 93 reporter.createMessage( | 97 reporter.createMessage( |
| 94 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), | 98 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), |
| 95 ]); | 99 ]); |
| 96 } | 100 } |
| 97 } | 101 } |
| OLD | NEW |