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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1846703002: Fix for infinite resursion while finding a concrete method. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | 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.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (parameter.parameterKind != ParameterKind.REQUIRED) { 561 if (parameter.parameterKind != ParameterKind.REQUIRED) {
562 return false; 562 return false;
563 } 563 }
564 } 564 }
565 return true; 565 return true;
566 } 566 }
567 567
568 @override 568 @override
569 MethodElement lookUpConcreteMethod( 569 MethodElement lookUpConcreteMethod(
570 String methodName, LibraryElement library) => 570 String methodName, LibraryElement library) =>
571 _internalLookUpConcreteMethod(methodName, library, true); 571 _internalLookUpConcreteMethod(
572 methodName, library, true, new HashSet<ClassElement>());
572 573
573 @override 574 @override
574 PropertyAccessorElement lookUpGetter( 575 PropertyAccessorElement lookUpGetter(
575 String getterName, LibraryElement library) => 576 String getterName, LibraryElement library) =>
576 _internalLookUpGetter(getterName, library, true); 577 _internalLookUpGetter(getterName, library, true);
577 578
578 @override 579 @override
579 PropertyAccessorElement lookUpInheritedConcreteGetter( 580 PropertyAccessorElement lookUpInheritedConcreteGetter(
580 String getterName, LibraryElement library) => 581 String getterName, LibraryElement library) =>
581 _internalLookUpConcreteGetter(getterName, library, false); 582 _internalLookUpConcreteGetter(getterName, library, false);
582 583
583 @override 584 @override
584 MethodElement lookUpInheritedConcreteMethod( 585 MethodElement lookUpInheritedConcreteMethod(
585 String methodName, LibraryElement library) => 586 String methodName, LibraryElement library) =>
586 _internalLookUpConcreteMethod(methodName, library, false); 587 _internalLookUpConcreteMethod(
588 methodName, library, false, new HashSet<ClassElement>());
587 589
588 @override 590 @override
589 PropertyAccessorElement lookUpInheritedConcreteSetter( 591 PropertyAccessorElement lookUpInheritedConcreteSetter(
590 String setterName, LibraryElement library) => 592 String setterName, LibraryElement library) =>
591 _internalLookUpConcreteSetter(setterName, library, false); 593 _internalLookUpConcreteSetter(setterName, library, false);
592 594
593 @override 595 @override
594 MethodElement lookUpInheritedMethod( 596 MethodElement lookUpInheritedMethod(
595 String methodName, LibraryElement library) => 597 String methodName, LibraryElement library) =>
596 _internalLookUpMethod(methodName, library, false); 598 _internalLookUpMethod(
599 methodName, library, false, new HashSet<ClassElement>());
597 600
598 @override 601 @override
599 MethodElement lookUpMethod(String methodName, LibraryElement library) => 602 MethodElement lookUpMethod(String methodName, LibraryElement library) =>
600 _internalLookUpMethod(methodName, library, true); 603 _internalLookUpMethod(
604 methodName, library, true, new HashSet<ClassElement>());
601 605
602 @override 606 @override
603 PropertyAccessorElement lookUpSetter( 607 PropertyAccessorElement lookUpSetter(
604 String setterName, LibraryElement library) => 608 String setterName, LibraryElement library) =>
605 _internalLookUpSetter(setterName, library, true); 609 _internalLookUpSetter(setterName, library, true);
606 610
607 @override 611 @override
608 void visitChildren(ElementVisitor visitor) { 612 void visitChildren(ElementVisitor visitor) {
609 super.visitChildren(visitor); 613 super.visitChildren(visitor);
610 safelyVisitChildren(_accessors, visitor); 614 safelyVisitChildren(_accessors, visitor);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 if (definingClass is! ClassElement) { 748 if (definingClass is! ClassElement) {
745 return null; 749 return null;
746 } 750 }
747 getter = getImpl(definingClass) 751 getter = getImpl(definingClass)
748 ._internalLookUpGetter(getterName, library, false); 752 ._internalLookUpGetter(getterName, library, false);
749 } 753 }
750 return getter; 754 return getter;
751 } 755 }
752 756
753 MethodElement _internalLookUpConcreteMethod( 757 MethodElement _internalLookUpConcreteMethod(
754 String methodName, LibraryElement library, bool includeThisClass) { 758 String methodName,
755 MethodElement method = 759 LibraryElement library,
756 _internalLookUpMethod(methodName, library, includeThisClass); 760 bool includeThisClass,
761 HashSet<ClassElement> visitedClasses) {
762 MethodElement method = _internalLookUpMethod(
763 methodName, library, includeThisClass, visitedClasses);
757 while (method != null && method.isAbstract) { 764 while (method != null && method.isAbstract) {
758 ClassElement definingClass = method.enclosingElement; 765 ClassElement definingClass = method.enclosingElement;
759 if (definingClass == null) { 766 if (definingClass == null) {
760 return null; 767 return null;
761 } 768 }
762 method = definingClass.lookUpInheritedMethod(methodName, library); 769 method = getImpl(definingClass)
770 ._internalLookUpMethod(methodName, library, false, visitedClasses);
763 } 771 }
764 return method; 772 return method;
765 } 773 }
766 774
767 PropertyAccessorElement _internalLookUpConcreteSetter( 775 PropertyAccessorElement _internalLookUpConcreteSetter(
768 String setterName, LibraryElement library, bool includeThisClass) { 776 String setterName, LibraryElement library, bool includeThisClass) {
769 PropertyAccessorElement setter = 777 PropertyAccessorElement setter =
770 _internalLookUpSetter(setterName, library, includeThisClass); 778 _internalLookUpSetter(setterName, library, includeThisClass);
771 while (setter != null && setter.isAbstract) { 779 while (setter != null && setter.isAbstract) {
772 Element definingClass = setter.enclosingElement; 780 Element definingClass = setter.enclosingElement;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } 813 }
806 currentElement = supertype.element; 814 currentElement = supertype.element;
807 PropertyAccessorElement element = currentElement.getGetter(getterName); 815 PropertyAccessorElement element = currentElement.getGetter(getterName);
808 if (element != null && element.isAccessibleIn(library)) { 816 if (element != null && element.isAccessibleIn(library)) {
809 return element; 817 return element;
810 } 818 }
811 } 819 }
812 return null; 820 return null;
813 } 821 }
814 822
815 MethodElement _internalLookUpMethod( 823 MethodElement _internalLookUpMethod(String methodName, LibraryElement library,
816 String methodName, LibraryElement library, bool includeThisClass) { 824 bool includeThisClass, HashSet<ClassElement> visitedClasses) {
817 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
818 ClassElement currentElement = this; 825 ClassElement currentElement = this;
819 if (includeThisClass) { 826 if (includeThisClass) {
820 MethodElement element = currentElement.getMethod(methodName); 827 MethodElement element = currentElement.getMethod(methodName);
821 if (element != null && element.isAccessibleIn(library)) { 828 if (element != null && element.isAccessibleIn(library)) {
822 return element; 829 return element;
823 } 830 }
824 } 831 }
825 while (currentElement != null && visitedClasses.add(currentElement)) { 832 while (currentElement != null && visitedClasses.add(currentElement)) {
826 for (InterfaceType mixin in currentElement.mixins.reversed) { 833 for (InterfaceType mixin in currentElement.mixins.reversed) {
827 ClassElement mixinElement = mixin.element; 834 ClassElement mixinElement = mixin.element;
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4958 4965
4959 @override 4966 @override
4960 void visitElement(Element element) { 4967 void visitElement(Element element) {
4961 int offset = element.nameOffset; 4968 int offset = element.nameOffset;
4962 if (offset != -1) { 4969 if (offset != -1) {
4963 map[offset] = element; 4970 map[offset] = element;
4964 } 4971 }
4965 super.visitElement(element); 4972 super.visitElement(element);
4966 } 4973 }
4967 } 4974 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698