| 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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1282     // current class against definitions here and in superclasses. | 1282     // current class against definitions here and in superclasses. | 
| 1283     var localInterfaces = new Set<InterfaceType>(); | 1283     var localInterfaces = new Set<InterfaceType>(); | 
| 1284     var type = element.type; | 1284     var type = element.type; | 
| 1285     type.interfaces.forEach((i) => find(i, localInterfaces)); | 1285     type.interfaces.forEach((i) => find(i, localInterfaces)); | 
| 1286     _checkInterfacesOverrides(type, localInterfaces, seen, | 1286     _checkInterfacesOverrides(type, localInterfaces, seen, | 
| 1287         includeParents: true, classNode: node); | 1287         includeParents: true, classNode: node); | 
| 1288 | 1288 | 
| 1289     // Check also how we override locally the interfaces from parent classes if | 1289     // Check also how we override locally the interfaces from parent classes if | 
| 1290     // the parent class is abstract. Otherwise, these will be checked as | 1290     // the parent class is abstract. Otherwise, these will be checked as | 
| 1291     // overrides on the concrete superclass. | 1291     // overrides on the concrete superclass. | 
|  | 1292     // We detect superclass circularities using the "tortoise and hare" | 
|  | 1293     // algorithm. | 
| 1292     var superInterfaces = new Set<InterfaceType>(); | 1294     var superInterfaces = new Set<InterfaceType>(); | 
| 1293     var parent = type.superclass; | 1295     var parent = type.superclass; | 
|  | 1296     var hare = type.superclass?.superclass; | 
| 1294     // TODO(sigmund): we don't seem to be reporting the analyzer error that a | 1297     // TODO(sigmund): we don't seem to be reporting the analyzer error that a | 
| 1295     // non-abstract class is not implementing an interface. See | 1298     // non-abstract class is not implementing an interface. See | 
| 1296     // https://github.com/dart-lang/dart-dev-compiler/issues/25 | 1299     // https://github.com/dart-lang/dart-dev-compiler/issues/25 | 
| 1297     while (parent != null && parent.element.isAbstract) { | 1300     while (parent != null && parent.element.isAbstract) { | 
|  | 1301       if (identical(parent, hare)) break; | 
| 1298       parent.interfaces.forEach((i) => find(i, superInterfaces)); | 1302       parent.interfaces.forEach((i) => find(i, superInterfaces)); | 
| 1299       parent = parent.superclass; | 1303       parent = parent.superclass; | 
|  | 1304       hare = hare?.superclass?.superclass; | 
| 1300     } | 1305     } | 
| 1301     _checkInterfacesOverrides(type, superInterfaces, seen, | 1306     _checkInterfacesOverrides(type, superInterfaces, seen, | 
| 1302         includeParents: false, classNode: node); | 1307         includeParents: false, classNode: node); | 
| 1303   } | 1308   } | 
| 1304 | 1309 | 
| 1305   /// Check that individual methods and fields in [node] correctly override | 1310   /// Check that individual methods and fields in [node] correctly override | 
| 1306   /// the declarations in [baseType]. | 1311   /// the declarations in [baseType]. | 
| 1307   /// | 1312   /// | 
| 1308   /// The [errorLocation] node indicates where errors are reported, see | 1313   /// The [errorLocation] node indicates where errors are reported, see | 
| 1309   /// [_checkSingleOverride] for more details. | 1314   /// [_checkSingleOverride] for more details. | 
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1595   } | 1600   } | 
| 1596 | 1601 | 
| 1597   /// If node is a [ClassDeclaration] returns its members, otherwise if node is | 1602   /// If node is a [ClassDeclaration] returns its members, otherwise if node is | 
| 1598   /// a [ClassTypeAlias] this returns an empty list. | 1603   /// a [ClassTypeAlias] this returns an empty list. | 
| 1599   WithClause _withClause(Declaration node) { | 1604   WithClause _withClause(Declaration node) { | 
| 1600     return node is ClassDeclaration | 1605     return node is ClassDeclaration | 
| 1601         ? node.withClause | 1606         ? node.withClause | 
| 1602         : (node as ClassTypeAlias).withClause; | 1607         : (node as ClassTypeAlias).withClause; | 
| 1603   } | 1608   } | 
| 1604 } | 1609 } | 
| OLD | NEW | 
|---|