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 analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 Source source = addSource(code); | 1474 Source source = addSource(code); |
1475 LibraryElement library = resolve2(source); | 1475 LibraryElement library = resolve2(source); |
1476 assertNoErrors(source); | 1476 assertNoErrors(source); |
1477 verify([source]); | 1477 verify([source]); |
1478 CompilationUnit unit = resolveCompilationUnit(source, library); | 1478 CompilationUnit unit = resolveCompilationUnit(source, library); |
1479 SimpleIdentifier identifier = EngineTestCase.findNode( | 1479 SimpleIdentifier identifier = EngineTestCase.findNode( |
1480 unit, code, "context", (node) => node is SimpleIdentifier); | 1480 unit, code, "context", (node) => node is SimpleIdentifier); |
1481 expect(identifier.propagatedType.name, "CanvasRenderingContext2D"); | 1481 expect(identifier.propagatedType.name, "CanvasRenderingContext2D"); |
1482 } | 1482 } |
1483 | 1483 |
1484 void test_finalPropertyInducingVariable_classMember_instance() { | |
1485 addNamedSource( | |
1486 "/lib.dart", | |
1487 r''' | |
1488 class A { | |
1489 final v = 0; | |
1490 }'''); | |
1491 String code = r''' | |
1492 import 'lib.dart'; | |
1493 f(A a) { | |
1494 return a.v; // marker | |
1495 }'''; | |
1496 assertTypeOfMarkedExpression( | |
1497 code, typeProvider.dynamicType, typeProvider.intType); | |
1498 } | |
1499 | |
1500 void test_finalPropertyInducingVariable_classMember_instance_inherited() { | |
1501 addNamedSource( | |
1502 "/lib.dart", | |
1503 r''' | |
1504 class A { | |
1505 final v = 0; | |
1506 }'''); | |
1507 String code = r''' | |
1508 import 'lib.dart'; | |
1509 class B extends A { | |
1510 m() { | |
1511 return v; // marker | |
1512 } | |
1513 }'''; | |
1514 assertTypeOfMarkedExpression( | |
1515 code, typeProvider.dynamicType, typeProvider.intType); | |
1516 } | |
1517 | |
1518 void | |
1519 test_finalPropertyInducingVariable_classMember_instance_propagatedTarget()
{ | |
1520 addNamedSource( | |
1521 "/lib.dart", | |
1522 r''' | |
1523 class A { | |
1524 final v = 0; | |
1525 }'''); | |
1526 String code = r''' | |
1527 import 'lib.dart'; | |
1528 f(p) { | |
1529 if (p is A) { | |
1530 return p.v; // marker | |
1531 } | |
1532 }'''; | |
1533 assertTypeOfMarkedExpression( | |
1534 code, typeProvider.dynamicType, typeProvider.intType); | |
1535 } | |
1536 | |
1537 void test_finalPropertyInducingVariable_classMember_instance_unprefixed() { | |
1538 String code = r''' | |
1539 class A { | |
1540 final v = 0; | |
1541 m() { | |
1542 v; // marker | |
1543 } | |
1544 }'''; | |
1545 assertTypeOfMarkedExpression( | |
1546 code, typeProvider.dynamicType, typeProvider.intType); | |
1547 } | |
1548 | |
1549 void test_finalPropertyInducingVariable_classMember_static() { | |
1550 addNamedSource( | |
1551 "/lib.dart", | |
1552 r''' | |
1553 class A { | |
1554 static final V = 0; | |
1555 }'''); | |
1556 String code = r''' | |
1557 import 'lib.dart'; | |
1558 f() { | |
1559 return A.V; // marker | |
1560 }'''; | |
1561 assertTypeOfMarkedExpression( | |
1562 code, typeProvider.dynamicType, typeProvider.intType); | |
1563 } | |
1564 | |
1565 void test_finalPropertyInducingVariable_topLevelVariable_prefixed() { | |
1566 addNamedSource("/lib.dart", "final V = 0;"); | |
1567 String code = r''' | |
1568 import 'lib.dart' as p; | |
1569 f() { | |
1570 var v2 = p.V; // marker prefixed | |
1571 }'''; | |
1572 assertTypeOfMarkedExpression( | |
1573 code, typeProvider.dynamicType, typeProvider.intType); | |
1574 } | |
1575 | |
1576 void test_finalPropertyInducingVariable_topLevelVariable_simple() { | |
1577 addNamedSource("/lib.dart", "final V = 0;"); | |
1578 String code = r''' | |
1579 import 'lib.dart'; | |
1580 f() { | |
1581 return V; // marker simple | |
1582 }'''; | |
1583 assertTypeOfMarkedExpression( | |
1584 code, typeProvider.dynamicType, typeProvider.intType); | |
1585 } | |
1586 | |
1587 void test_forEach() { | 1484 void test_forEach() { |
1588 String code = r''' | 1485 String code = r''' |
1589 main() { | 1486 main() { |
1590 var list = <String> []; | 1487 var list = <String> []; |
1591 for (var e in list) { | 1488 for (var e in list) { |
1592 e; | 1489 e; |
1593 } | 1490 } |
1594 }'''; | 1491 }'''; |
1595 Source source = addSource(code); | 1492 Source source = addSource(code); |
1596 LibraryElement library = resolve2(source); | 1493 LibraryElement library = resolve2(source); |
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3635 */ | 3532 */ |
3636 class _StaleElement extends ElementImpl { | 3533 class _StaleElement extends ElementImpl { |
3637 _StaleElement() : super("_StaleElement", -1); | 3534 _StaleElement() : super("_StaleElement", -1); |
3638 | 3535 |
3639 @override | 3536 @override |
3640 get kind => throw "_StaleElement's kind shouldn't be accessed"; | 3537 get kind => throw "_StaleElement's kind shouldn't be accessed"; |
3641 | 3538 |
3642 @override | 3539 @override |
3643 accept(_) => throw "_StaleElement shouldn't be visited"; | 3540 accept(_) => throw "_StaleElement shouldn't be visited"; |
3644 } | 3541 } |
OLD | NEW |