| 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
| 6 // refactored to fit into analyzer. | 6 // refactored to fit into analyzer. |
| 7 library analyzer.src.task.strong.checker; | 7 library analyzer.src.task.strong.checker; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 _checker._recordMessage( | 1427 _checker._recordMessage( |
| 1428 errorLocation, StrongModeCode.INVALID_FIELD_OVERRIDE, [ | 1428 errorLocation, StrongModeCode.INVALID_FIELD_OVERRIDE, [ |
| 1429 element.enclosingElement.name, | 1429 element.enclosingElement.name, |
| 1430 element.name, | 1430 element.name, |
| 1431 subType, | 1431 subType, |
| 1432 type, | 1432 type, |
| 1433 baseType | 1433 baseType |
| 1434 ]); | 1434 ]); |
| 1435 } | 1435 } |
| 1436 } | 1436 } |
| 1437 FunctionType concreteSubType = subType; | 1437 if (!rules.isOverrideSubtypeOf(subType, baseType)) { |
| 1438 FunctionType concreteBaseType = baseType; | |
| 1439 if (concreteSubType.typeFormals.isNotEmpty) { | |
| 1440 if (concreteBaseType.typeFormals.isEmpty) { | |
| 1441 concreteSubType = rules.instantiateToBounds(concreteSubType); | |
| 1442 } | |
| 1443 } | |
| 1444 | |
| 1445 if (!rules.isOverrideSubtypeOf(concreteSubType, concreteBaseType)) { | |
| 1446 ErrorCode errorCode; | 1438 ErrorCode errorCode; |
| 1447 if (errorLocation is ExtendsClause) { | 1439 if (errorLocation is ExtendsClause) { |
| 1448 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_BASE; | 1440 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_BASE; |
| 1449 } else if (errorLocation.parent is WithClause) { | 1441 } else if (errorLocation.parent is WithClause) { |
| 1450 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_MIXIN; | 1442 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_MIXIN; |
| 1451 } else { | 1443 } else { |
| 1452 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE; | 1444 errorCode = StrongModeCode.INVALID_METHOD_OVERRIDE; |
| 1453 } | 1445 } |
| 1454 | 1446 |
| 1455 _checker._recordMessage(errorLocation, errorCode, [ | 1447 _checker._recordMessage(errorLocation, errorCode, [ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 var visited = new Set<InterfaceType>(); | 1488 var visited = new Set<InterfaceType>(); |
| 1497 do { | 1489 do { |
| 1498 visited.add(current); | 1490 visited.add(current); |
| 1499 current.mixins.reversed.forEach( | 1491 current.mixins.reversed.forEach( |
| 1500 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); | 1492 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); |
| 1501 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); | 1493 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); |
| 1502 current = current.superclass; | 1494 current = current.superclass; |
| 1503 } while (!current.isObject && !visited.contains(current)); | 1495 } while (!current.isObject && !visited.contains(current)); |
| 1504 } | 1496 } |
| 1505 } | 1497 } |
| OLD | NEW |