| 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../common/names.dart' show Identifiers, Names, Selectors; | 6 import '../common/names.dart' show Identifiers, Names, Selectors; |
| 7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../types/types.dart'; | 10 import '../types/types.dart'; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (otherImpls.contains(element)) { | 143 if (otherImpls.contains(element)) { |
| 144 return NsmCategory.OTHER; | 144 return NsmCategory.OTHER; |
| 145 } | 145 } |
| 146 if (notApplicableImpls.contains(element)) { | 146 if (notApplicableImpls.contains(element)) { |
| 147 return NsmCategory.NOT_APPLICABLE; | 147 return NsmCategory.NOT_APPLICABLE; |
| 148 } | 148 } |
| 149 if (!Selectors.noSuchMethod_.signatureApplies(element)) { | 149 if (!Selectors.noSuchMethod_.signatureApplies(element)) { |
| 150 notApplicableImpls.add(element); | 150 notApplicableImpls.add(element); |
| 151 return NsmCategory.NOT_APPLICABLE; | 151 return NsmCategory.NOT_APPLICABLE; |
| 152 } | 152 } |
| 153 if (_isDefaultNoSuchMethodImplementation(element)) { | 153 if (isDefaultNoSuchMethodImplementation(element)) { |
| 154 defaultImpls.add(element); | 154 defaultImpls.add(element); |
| 155 return NsmCategory.DEFAULT; | 155 return NsmCategory.DEFAULT; |
| 156 } else if (_hasForwardingSyntax(element)) { | 156 } else if (_hasForwardingSyntax(element)) { |
| 157 // If the implementation is 'noSuchMethod(x) => super.noSuchMethod(x);' | 157 // If the implementation is 'noSuchMethod(x) => super.noSuchMethod(x);' |
| 158 // then it is in the same category as the super call. | 158 // then it is in the same category as the super call. |
| 159 Element superCall = | 159 Element superCall = |
| 160 element.enclosingClass.lookupSuperByName(Names.noSuchMethod_); | 160 element.enclosingClass.lookupSuperByName(Names.noSuchMethod_); |
| 161 NsmCategory category = _categorizeImpl(superCall); | 161 NsmCategory category = _categorizeImpl(superCall); |
| 162 switch (category) { | 162 switch (category) { |
| 163 case NsmCategory.DEFAULT: | 163 case NsmCategory.DEFAULT: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 179 return category; | 179 return category; |
| 180 } else if (_hasThrowingSyntax(element)) { | 180 } else if (_hasThrowingSyntax(element)) { |
| 181 throwingImpls.add(element); | 181 throwingImpls.add(element); |
| 182 return NsmCategory.THROWING; | 182 return NsmCategory.THROWING; |
| 183 } else { | 183 } else { |
| 184 otherImpls.add(element); | 184 otherImpls.add(element); |
| 185 return NsmCategory.OTHER; | 185 return NsmCategory.OTHER; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool _isDefaultNoSuchMethodImplementation(FunctionElement element) { | 189 bool isDefaultNoSuchMethodImplementation(FunctionElement element) { |
| 190 ClassElement classElement = element.enclosingClass; | 190 ClassElement classElement = element.enclosingClass; |
| 191 return classElement == _compiler.coreClasses.objectClass || | 191 return classElement == _compiler.coreClasses.objectClass || |
| 192 classElement == _backend.helpers.jsInterceptorClass || | 192 classElement == _backend.helpers.jsInterceptorClass || |
| 193 classElement == _backend.helpers.jsNullClass; | 193 classElement == _backend.helpers.jsNullClass; |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool _hasForwardingSyntax(FunctionElement element) { | 196 bool _hasForwardingSyntax(FunctionElement element) { |
| 197 // At this point we know that this is signature-compatible with | 197 // At this point we know that this is signature-compatible with |
| 198 // Object.noSuchMethod, but it may have more than one argument as long as | 198 // Object.noSuchMethod, but it may have more than one argument as long as |
| 199 // it only has one required argument. | 199 // it only has one required argument. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (body.statements.nodes.head is ExpressionStatement) { | 262 if (body.statements.nodes.head is ExpressionStatement) { |
| 263 ExpressionStatement stmt = body.statements.nodes.head; | 263 ExpressionStatement stmt = body.statements.nodes.head; |
| 264 return stmt.expression is Throw; | 264 return stmt.expression is Throw; |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 return false; | 267 return false; |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 enum NsmCategory { DEFAULT, THROWING, NOT_APPLICABLE, OTHER, } | 271 enum NsmCategory { DEFAULT, THROWING, NOT_APPLICABLE, OTHER, } |
| OLD | NEW |