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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 581733002: New analyzer snaphot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rollback Java changes Created 6 years, 3 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:
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 3b64b515fc2eb1ad3323c481ba1f9f720f20a940..79694a2f91e4282951dbba2f7767fbc7d234cff8 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -19336,9 +19336,24 @@ class ResolverVisitor extends ScopedVisitor {
return;
}
DartType currentType = _getBestType(element);
- // If we aren't allowing precision loss then the third condition checks that we
+ // If we aren't allowing precision loss then the third and fourth conditions check that we
// aren't losing precision.
- if (currentType == null || allowPrecisionLoss || !currentType.isMoreSpecificThan(potentialType)) {
+ //
+ // Let [C] be the current type and [P] be the potential type. When we aren't allowing
+ // precision loss -- which is the case for is-checks -- we check that [! (C << P)] or [P << C].
+ // The second check, that [P << C], is analogous to part of the Dart Language Spec rule
+ // for type promotion under is-checks (in the analogy [T] is [P] and [S] is [C]):
+ //
+ // An is-expression of the form [v is T] shows that [v] has type [T] iff [T] is more
+ // specific than the type [S] of the expression [v] and both [T != dynamic] and
+ // [S != dynamic].
+ //
+ // It also covers an important case that is not applicable in the spec: for union types, we
+ // want an is-check to promote from an union type to (a subtype of) any of its members.
+ //
+ // The first check, that [! (C << P)], covers the case where [P] and [C] are unrelated types;
+ // This case is not addressed in the spec for static types.
+ if (currentType == null || allowPrecisionLoss || !currentType.isMoreSpecificThan(potentialType) || potentialType.isMoreSpecificThan(currentType)) {
if (element is PropertyInducingElement) {
PropertyInducingElement variable = element;
if (!variable.isConst && !variable.isFinal) {
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698