OLD | NEW |
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 engine.resolver_test; | 5 library engine.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 12582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12593 c = true; | 12593 c = true; |
12594 break L; | 12594 break L; |
12595 } | 12595 } |
12596 x; // marker | 12596 x; // marker |
12597 }'''; | 12597 }'''; |
12598 DartType t = _findMarkedIdentifier(code, "; // marker").propagatedType; | 12598 DartType t = _findMarkedIdentifier(code, "; // marker").propagatedType; |
12599 expect(typeProvider.intType.isSubtypeOf(t), isTrue); | 12599 expect(typeProvider.intType.isSubtypeOf(t), isTrue); |
12600 expect(typeProvider.stringType.isSubtypeOf(t), isTrue); | 12600 expect(typeProvider.stringType.isSubtypeOf(t), isTrue); |
12601 } | 12601 } |
12602 | 12602 |
| 12603 void test_mutatedOutsideScope() { |
| 12604 // https://code.google.com/p/dart/issues/detail?id=22732 |
| 12605 Source source = addSource(r''' |
| 12606 class Base { |
| 12607 } |
| 12608 |
| 12609 class Derived extends Base { |
| 12610 get y => null; |
| 12611 } |
| 12612 |
| 12613 class C { |
| 12614 void f() { |
| 12615 Base x = null; |
| 12616 if (x is Derived) { |
| 12617 print(x.y); // BAD |
| 12618 } |
| 12619 x = null; |
| 12620 } |
| 12621 } |
| 12622 |
| 12623 void g() { |
| 12624 Base x = null; |
| 12625 if (x is Derived) { |
| 12626 print(x.y); // GOOD |
| 12627 } |
| 12628 x = null; |
| 12629 }'''); |
| 12630 resolve(source); |
| 12631 assertNoErrors(source); |
| 12632 } |
| 12633 |
12603 void test_objectMethodOnDynamicExpression_doubleEquals() { | 12634 void test_objectMethodOnDynamicExpression_doubleEquals() { |
12604 // https://code.google.com/p/dart/issues/detail?id=20342 | 12635 // https://code.google.com/p/dart/issues/detail?id=20342 |
12605 // | 12636 // |
12606 // This was not actually part of Issue 20342, since the spec specifies a | 12637 // This was not actually part of Issue 20342, since the spec specifies a |
12607 // static type of [bool] for [==] comparison and the implementation | 12638 // static type of [bool] for [==] comparison and the implementation |
12608 // was already consistent with the spec there. But, it's another | 12639 // was already consistent with the spec there. But, it's another |
12609 // [Object] method, so it's included here. | 12640 // [Object] method, so it's included here. |
12610 _assertTypeOfMarkedExpression(r''' | 12641 _assertTypeOfMarkedExpression(r''' |
12611 f1(x) { | 12642 f1(x) { |
12612 var v = (x == x); | 12643 var v = (x == x); |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13464 // check propagated type | 13495 // check propagated type |
13465 FunctionType propagatedType = node.propagatedType as FunctionType; | 13496 FunctionType propagatedType = node.propagatedType as FunctionType; |
13466 expect(propagatedType.returnType, test.typeProvider.stringType); | 13497 expect(propagatedType.returnType, test.typeProvider.stringType); |
13467 } on AnalysisException catch (e, stackTrace) { | 13498 } on AnalysisException catch (e, stackTrace) { |
13468 thrownException[0] = new CaughtException(e, stackTrace); | 13499 thrownException[0] = new CaughtException(e, stackTrace); |
13469 } | 13500 } |
13470 } | 13501 } |
13471 return null; | 13502 return null; |
13472 } | 13503 } |
13473 } | 13504 } |
OLD | NEW |