Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2708773002: Fix infinite loop when there is a cycle in the class hierarchy (issue 28837) (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4890 matching lines...) Expand 10 before | Expand all | Expand 10 after
4901 if (hasSuperInitializer) { 4901 if (hasSuperInitializer) {
4902 _errorReporter.reportErrorForNode( 4902 _errorReporter.reportErrorForNode(
4903 CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS, initializer); 4903 CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS, initializer);
4904 } 4904 }
4905 hasSuperInitializer = true; 4905 hasSuperInitializer = true;
4906 } 4906 }
4907 } 4907 }
4908 } 4908 }
4909 4909
4910 void _checkForMustCallSuper(MethodDeclaration node) { 4910 void _checkForMustCallSuper(MethodDeclaration node) {
4911 if (node.isStatic) {
4912 return;
4913 }
4911 MethodElement element = _findOverriddenMemberThatMustCallSuper(node); 4914 MethodElement element = _findOverriddenMemberThatMustCallSuper(node);
4912 if (element != null) { 4915 if (element != null) {
4913 _InvocationCollector collector = new _InvocationCollector(); 4916 _InvocationCollector collector = new _InvocationCollector();
4914 node.accept(collector); 4917 node.accept(collector);
4915 if (!collector.superCalls.contains(element.name)) { 4918 if (!collector.superCalls.contains(element.name)) {
4916 _errorReporter.reportErrorForNode(HintCode.MUST_CALL_SUPER, node.name, 4919 _errorReporter.reportErrorForNode(HintCode.MUST_CALL_SUPER, node.name,
4917 [element.enclosingElement.name]); 4920 [element.enclosingElement.name]);
4918 } 4921 }
4919 } 4922 }
4920 } 4923 }
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after
6401 if (member == null) { 6404 if (member == null) {
6402 return null; 6405 return null;
6403 } 6406 }
6404 ClassElement classElement = 6407 ClassElement classElement =
6405 member.getAncestor((element) => element is ClassElement); 6408 member.getAncestor((element) => element is ClassElement);
6406 if (classElement == null) { 6409 if (classElement == null) {
6407 return null; 6410 return null;
6408 } 6411 }
6409 String name = member.name; 6412 String name = member.name;
6410 ClassElement superclass = classElement.supertype?.element; 6413 ClassElement superclass = classElement.supertype?.element;
6411 while (superclass != null) { 6414 Set<ClassElement> visitedClasses = new Set();
scheglov 2017/02/20 18:27:02 Type argument in creation?
Brian Wilkerson 2017/02/20 19:46:30 Done
6415 while (superclass != null && visitedClasses.add(superclass)) {
6412 ExecutableElement member = superclass.getMethod(name) ?? 6416 ExecutableElement member = superclass.getMethod(name) ??
6413 superclass.getGetter(name) ?? 6417 superclass.getGetter(name) ??
6414 superclass.getSetter(name); 6418 superclass.getSetter(name);
6415 if (member != null) { 6419 if (member != null) {
6416 return member; 6420 return member;
6417 } 6421 }
6418 superclass = superclass.supertype?.element; 6422 superclass = superclass.supertype?.element;
6419 } 6423 }
6420 return null; 6424 return null;
6421 } 6425 }
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
7077 class _InvocationCollector extends RecursiveAstVisitor { 7081 class _InvocationCollector extends RecursiveAstVisitor {
7078 final List<String> superCalls = <String>[]; 7082 final List<String> superCalls = <String>[];
7079 7083
7080 @override 7084 @override
7081 visitMethodInvocation(MethodInvocation node) { 7085 visitMethodInvocation(MethodInvocation node) {
7082 if (node.target is SuperExpression) { 7086 if (node.target is SuperExpression) {
7083 superCalls.add(node.methodName.name); 7087 superCalls.add(node.methodName.name);
7084 } 7088 }
7085 } 7089 }
7086 } 7090 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698