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

Side by Side Diff: lib/src/checker/rules.dart

Issue 1395643004: remove most of the StrongOptions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebase Created 5 years, 2 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 | « lib/src/checker/resolver.dart ('k') | lib/strong_mode.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) 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 library dev_compiler.src.checker.rules; 5 library dev_compiler.src.checker.rules;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/resolver.dart'; 9 import 'package:analyzer/src/generated/resolver.dart';
10 10
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 397
398 // Downcast if toT <: fromT 398 // Downcast if toT <: fromT
399 if (isSubTypeOf(toT, fromT)) return Coercion.cast(fromT, toT); 399 if (isSubTypeOf(toT, fromT)) return Coercion.cast(fromT, toT);
400 400
401 // Downcast if toT <===> fromT 401 // Downcast if toT <===> fromT
402 // The intention here is to allow casts that are sideways in the restricted 402 // The intention here is to allow casts that are sideways in the restricted
403 // type system, but allowed in the regular dart type system, since these 403 // type system, but allowed in the regular dart type system, since these
404 // are likely to succeed. The canonical example is List<dynamic> and 404 // are likely to succeed. The canonical example is List<dynamic> and
405 // Iterable<T> for some concrete T (e.g. Object). These are unrelated 405 // Iterable<T> for some concrete T (e.g. Object). These are unrelated
406 // in the restricted system, but List<dynamic> <: Iterable<T> in dart. 406 // in the restricted system, but List<dynamic> <: Iterable<T> in dart.
407 if (options.relaxedCasts && fromT.isAssignableTo(toT)) { 407 if (fromT.isAssignableTo(toT)) {
408 return Coercion.cast(fromT, toT); 408 return Coercion.cast(fromT, toT);
409 } 409 }
410 return Coercion.error(); 410 return Coercion.error();
411 } 411 }
412 412
413 StaticInfo checkAssignment(Expression expr, DartType toT) { 413 StaticInfo checkAssignment(Expression expr, DartType toT) {
414 final fromT = getStaticType(expr); 414 final fromT = getStaticType(expr);
415 final Coercion c = _coerceTo(fromT, toT); 415 final Coercion c = _coerceTo(fromT, toT);
416 if (c is Identity) return null; 416 if (c is Identity) return null;
417 if (c is CoercionError) return new StaticTypeError(this, expr, toT); 417 if (c is CoercionError) return new StaticTypeError(this, expr, toT);
418 var reason = null; 418 var reason = null;
419 if (options.inferDownwards) { 419
420 var errors = <String>[]; 420 var errors = <String>[];
421 var ok = inferrer.inferExpression(expr, toT, errors); 421 var ok = inferrer.inferExpression(expr, toT, errors);
422 if (ok) return InferredType.create(this, expr, toT); 422 if (ok) return InferredType.create(this, expr, toT);
423 reason = (errors.isNotEmpty) ? errors.first : null; 423 reason = (errors.isNotEmpty) ? errors.first : null;
424 } 424
425 if (c is Cast) return DownCast.create(this, expr, c, reason: reason); 425 if (c is Cast) return DownCast.create(this, expr, c, reason: reason);
426 assert(false); 426 assert(false);
427 return null; 427 return null;
428 } 428 }
429 429
430 DartType elementType(Element e) { 430 DartType elementType(Element e) {
431 if (e == null) { 431 if (e == null) {
432 // Malformed code - just return dynamic. 432 // Malformed code - just return dynamic.
433 return provider.dynamicType; 433 return provider.dynamicType;
434 } 434 }
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 var entries = e.entries; 748 var entries = e.entries;
749 bool inferEntry(MapLiteralEntry entry) { 749 bool inferEntry(MapLiteralEntry entry) {
750 return _inferExpression(entry.key, kType, errors) && 750 return _inferExpression(entry.key, kType, errors) &&
751 _inferExpression(entry.value, vType, errors); 751 _inferExpression(entry.value, vType, errors);
752 } 752 }
753 var b = entries.every(inferEntry); 753 var b = entries.every(inferEntry);
754 if (b) annotateMapLiteral(e, targs); 754 if (b) annotateMapLiteral(e, targs);
755 return b; 755 return b;
756 } 756 }
757 } 757 }
OLDNEW
« no previous file with comments | « lib/src/checker/resolver.dart ('k') | lib/strong_mode.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698