| 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 analyzer.src.task.strong_mode; | 5 library analyzer.src.task.strong_mode; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // we must express its parameter and return types in terms of its own | 272 // we must express its parameter and return types in terms of its own |
| 273 // parameters. For example, given `m<T>(t)` overriding `m<S>(S s)` we | 273 // parameters. For example, given `m<T>(t)` overriding `m<S>(S s)` we |
| 274 // should infer this as `m<T>(T t)`. | 274 // should infer this as `m<T>(T t)`. |
| 275 // | 275 // |
| 276 List<DartType> typeFormals = | 276 List<DartType> typeFormals = |
| 277 TypeParameterTypeImpl.getTypes(element.type.typeFormals); | 277 TypeParameterTypeImpl.getTypes(element.type.typeFormals); |
| 278 | 278 |
| 279 List<FunctionType> overriddenTypes = new List<FunctionType>(); | 279 List<FunctionType> overriddenTypes = new List<FunctionType>(); |
| 280 for (ExecutableElement overriddenMethod in overriddenMethods) { | 280 for (ExecutableElement overriddenMethod in overriddenMethods) { |
| 281 FunctionType overriddenType = overriddenMethod.type; | 281 FunctionType overriddenType = overriddenMethod.type; |
| 282 if (overriddenType == null) { |
| 283 // TODO(brianwilkerson) I think the overridden method should always have |
| 284 // a type, but there appears to be a bug that causes it to sometimes be |
| 285 // null, we guard against that case by not performing inference. |
| 286 return; |
| 287 } |
| 282 if (overriddenType.typeFormals.isNotEmpty) { | 288 if (overriddenType.typeFormals.isNotEmpty) { |
| 283 if (overriddenType.typeFormals.length != typeFormals.length) { | 289 if (overriddenType.typeFormals.length != typeFormals.length) { |
| 284 return; | 290 return; |
| 285 } | 291 } |
| 286 overriddenType = overriddenType.instantiate(typeFormals); | 292 overriddenType = overriddenType.instantiate(typeFormals); |
| 287 } | 293 } |
| 288 overriddenTypes.add(overriddenType); | 294 overriddenTypes.add(overriddenType); |
| 289 } | 295 } |
| 290 | 296 |
| 291 // | 297 // |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 465 |
| 460 @override | 466 @override |
| 461 void visitSimpleIdentifier(SimpleIdentifier node) { | 467 void visitSimpleIdentifier(SimpleIdentifier node) { |
| 462 if (!node.inDeclarationContext()) { | 468 if (!node.inDeclarationContext()) { |
| 463 Element nonAccessor(Element element) { | 469 Element nonAccessor(Element element) { |
| 464 if (element is PropertyAccessorElement && element.isSynthetic) { | 470 if (element is PropertyAccessorElement && element.isSynthetic) { |
| 465 return element.variable; | 471 return element.variable; |
| 466 } | 472 } |
| 467 return element; | 473 return element; |
| 468 } | 474 } |
| 475 |
| 469 Element element = nonAccessor(node.staticElement); | 476 Element element = nonAccessor(node.staticElement); |
| 470 if (element is VariableElement && (filter == null || filter(element))) { | 477 if (element is VariableElement && (filter == null || filter(element))) { |
| 471 results.add(element); | 478 results.add(element); |
| 472 } | 479 } |
| 473 } | 480 } |
| 474 } | 481 } |
| 475 } | 482 } |
| 476 | 483 |
| 477 /** | 484 /** |
| 478 * A class of exception that is not used anywhere else. | 485 * A class of exception that is not used anywhere else. |
| 479 */ | 486 */ |
| 480 class _CycleException implements Exception {} | 487 class _CycleException implements Exception {} |
| OLD | NEW |