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

Unified Diff: pkg/analyzer/lib/src/task/strong_mode.dart

Issue 2743773004: Revert "Infer types of instance methods before any other inference." (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/strong_mode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/strong_mode.dart
diff --git a/pkg/analyzer/lib/src/task/strong_mode.dart b/pkg/analyzer/lib/src/task/strong_mode.dart
index c1ffe3b5d0986a283266e1badac991ccaa101d20..284a31ad55cc6386e4caa930421d87215029c06f 100644
--- a/pkg/analyzer/lib/src/task/strong_mode.dart
+++ b/pkg/analyzer/lib/src/task/strong_mode.dart
@@ -73,7 +73,7 @@ class InstanceMemberInferrer {
* The classes that have been visited while attempting to infer the types of
* instance members of some base class.
*/
- HashSet<ClassElementImpl> classesBeingInferred =
+ HashSet<ClassElementImpl> elementsBeingInferred =
new HashSet<ClassElementImpl>();
/**
@@ -102,17 +102,6 @@ class InstanceMemberInferrer {
}
/**
- * Infer types for all of the instance methods in [unit].
- */
- void inferInstanceMethods(CompilationUnitElement unit) {
- for (ClassElement classElement in unit.types) {
- try {
- _inferClassInstanceMethods(classElement);
- } on _CycleException {}
- }
- }
-
- /**
* Return `true` if the list of [elements] contains only methods.
*/
bool _allSameElementKind(
@@ -214,7 +203,7 @@ class InstanceMemberInferrer {
if (classElement.hasBeenInferred) {
return;
}
- if (!classesBeingInferred.add(classElement)) {
+ if (!elementsBeingInferred.add(classElement)) {
// We have found a circularity in the class hierarchy. For now we just
// stop trying to infer any type information for any classes that
// inherit from any class in the cycle. We could potentially limit the
@@ -235,6 +224,7 @@ class InstanceMemberInferrer {
//
classElement.fields.forEach(_inferField);
classElement.accessors.forEach(_inferExecutable);
+ classElement.methods.forEach(_inferExecutable);
//
// Infer initializing formal parameter types. This must happen after
// field types are inferred.
@@ -242,49 +232,7 @@ class InstanceMemberInferrer {
classElement.constructors.forEach(_inferConstructorFieldFormals);
classElement.hasBeenInferred = true;
} finally {
- classesBeingInferred.remove(classElement);
- }
- }
- }
-
- /**
- * Infer types for all of the instance methods in the given [classElement].
- */
- void _inferClassInstanceMethods(ClassElement classElement) {
- if (classElement is ClassElementImpl) {
- if (classElement.hasInferredInstanceMethods) {
- return;
- }
- if (!classesBeingInferred.add(classElement)) {
- // We have found a circularity in the class hierarchy. For now we just
- // stop trying to infer any type information for any classes that
- // inherit from any class in the cycle. We could potentially limit the
- // algorithm to only not inferring types in the classes in the cycle,
- // but it isn't clear that the results would be significantly better.
- throw new _CycleException();
- }
- try {
- //
- // Process supertypes first.
- //
- void processSupertype(InterfaceType type) {
- ClassElement element = type?.element;
- if (element != null) {
- _inferClassInstanceMethods(element);
- }
- }
-
- processSupertype(classElement.supertype);
- classElement.mixins.forEach(processSupertype);
- classElement.interfaces.forEach(processSupertype);
-
- //
- // Then infer the types for the instance methods in this class.
- //
- classElement.methods.forEach(_inferExecutable);
- classElement.hasInferredInstanceMethods = true;
- } finally {
- classesBeingInferred.remove(classElement);
+ elementsBeingInferred.remove(classElement);
}
}
}
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/strong_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698