| Index: pkg/analyzer/test/generated/all_the_rest_test.dart
|
| diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| index 70e1c732f7b3f4517f26a453e5616c95e2135e8e..246750afdf1cfdc9a7cc2819e006605dcfcc48a0 100644
|
| --- a/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| +++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
|
| @@ -1591,6 +1591,43 @@ class C {
|
| expect(method.isSynthetic, isFalse);
|
| }
|
|
|
| + void test_visitMethodDeclaration_duplicateField_synthetic() {
|
| + buildElementsForText(r'''
|
| +class A {
|
| + int f;
|
| + int get f => 42;
|
| +}
|
| +''');
|
| + ClassDeclaration classNode = compilationUnit.declarations.single;
|
| + // ClassElement
|
| + ClassElement classElement = classNode.element;
|
| + expect(classElement.fields, hasLength(2));
|
| + expect(classElement.accessors, hasLength(3));
|
| + FieldElement notSyntheticFieldElement = classElement.fields
|
| + .singleWhere((f) => f.displayName == 'f' && !f.isSynthetic);
|
| + FieldElement syntheticFieldElement = classElement.fields
|
| + .singleWhere((f) => f.displayName == 'f' && f.isSynthetic);
|
| + PropertyAccessorElement syntheticGetterElement = classElement.accessors
|
| + .singleWhere(
|
| + (a) => a.displayName == 'f' && a.isGetter && a.isSynthetic);
|
| + PropertyAccessorElement syntheticSetterElement = classElement.accessors
|
| + .singleWhere(
|
| + (a) => a.displayName == 'f' && a.isSetter && a.isSynthetic);
|
| + PropertyAccessorElement notSyntheticGetterElement = classElement.accessors
|
| + .singleWhere(
|
| + (a) => a.displayName == 'f' && a.isGetter && !a.isSynthetic);
|
| + expect(notSyntheticFieldElement.getter, same(syntheticGetterElement));
|
| + expect(notSyntheticFieldElement.setter, same(syntheticSetterElement));
|
| + expect(syntheticFieldElement.getter, same(notSyntheticGetterElement));
|
| + expect(syntheticFieldElement.setter, isNull);
|
| + // class members nodes and their elements
|
| + FieldDeclaration fieldDeclNode = classNode.members[0];
|
| + VariableDeclaration fieldNode = fieldDeclNode.fields.variables.single;
|
| + MethodDeclaration getterNode = classNode.members[1];
|
| + expect(fieldNode.element, notSyntheticFieldElement);
|
| + expect(getterNode.element, notSyntheticGetterElement);
|
| + }
|
| +
|
| void test_visitMethodDeclaration_external() {
|
| // external m();
|
| ElementHolder holder = new ElementHolder();
|
| @@ -2565,20 +2602,6 @@ class C {
|
|
|
| @reflectiveTest
|
| class ElementLocatorTest extends ResolverTestCase {
|
| - void test_locate_ExportDirective() {
|
| - AstNode id = _findNodeIn("export", "export 'dart:core';");
|
| - Element element = ElementLocator.locate(id);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ExportElement, ExportElement, element);
|
| - }
|
| -
|
| - void test_locate_Identifier_libraryDirective() {
|
| - AstNode id = _findNodeIn("foo", "library foo.bar;");
|
| - Element element = ElementLocator.locate(id);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryElement, LibraryElement, element);
|
| - }
|
| -
|
| void fail_locate_Identifier_partOfDirective() {
|
| // Can't resolve the library element without the library declaration.
|
| // AstNode id = findNodeIn("foo", "part of foo.bar;");
|
| @@ -2643,6 +2666,13 @@ class A {
|
| (obj) => obj is ConstructorElement, ConstructorElement, element);
|
| }
|
|
|
| + void test_locate_ExportDirective() {
|
| + AstNode id = _findNodeIn("export", "export 'dart:core';");
|
| + Element element = ElementLocator.locate(id);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is ExportElement, ExportElement, element);
|
| + }
|
| +
|
| void test_locate_FunctionDeclaration() {
|
| AstNode id = _findNodeIn("f", "int f() => 3;");
|
| FunctionDeclaration declaration =
|
| @@ -2724,6 +2754,13 @@ class A {
|
| (obj) => obj is FieldElement, FieldElement, element);
|
| }
|
|
|
| + void test_locate_Identifier_libraryDirective() {
|
| + AstNode id = _findNodeIn("foo", "library foo.bar;");
|
| + Element element = ElementLocator.locate(id);
|
| + EngineTestCase.assertInstanceOf(
|
| + (obj) => obj is LibraryElement, LibraryElement, element);
|
| + }
|
| +
|
| void test_locate_Identifier_propertyAccess() {
|
| AstNode id = _findNodeIn(
|
| "length",
|
| @@ -3467,14 +3504,6 @@ class ExitDetectorTest extends ParserTestCase {
|
| expect(new ExitDetector(), isNotNull);
|
| }
|
|
|
| - void test_doStatement_return() {
|
| - _assertTrue("{ do { return null; } while (1 == 2); }");
|
| - }
|
| -
|
| - void test_doStatement_throwCondition() {
|
| - _assertTrue("{ do {} while (throw ''); }");
|
| - }
|
| -
|
| void test_doStatement_break_and_throw() {
|
| _assertFalse("{ do { if (1==1) break; throw 'T'; } while (0==1); }");
|
| }
|
| @@ -3483,12 +3512,12 @@ class ExitDetectorTest extends ParserTestCase {
|
| _assertFalse("{ do { if (1==1) continue; throw 'T'; } while (0==1); }");
|
| }
|
|
|
| - void test_doStatement_continueInSwitch_and_throw() {
|
| + void test_doStatement_continueDoInSwitch_and_throw() {
|
| _assertFalse('''
|
| {
|
| - do {
|
| + D: do {
|
| switch (1) {
|
| - L: case 0: continue;
|
| + L: case 0: continue D;
|
| M: case 1: break;
|
| }
|
| throw 'T';
|
| @@ -3496,12 +3525,12 @@ class ExitDetectorTest extends ParserTestCase {
|
| }''');
|
| }
|
|
|
| - void test_doStatement_continueDoInSwitch_and_throw() {
|
| + void test_doStatement_continueInSwitch_and_throw() {
|
| _assertFalse('''
|
| {
|
| - D: do {
|
| + do {
|
| switch (1) {
|
| - L: case 0: continue D;
|
| + L: case 0: continue;
|
| M: case 1: break;
|
| }
|
| throw 'T';
|
| @@ -3509,6 +3538,14 @@ class ExitDetectorTest extends ParserTestCase {
|
| }''');
|
| }
|
|
|
| + void test_doStatement_return() {
|
| + _assertTrue("{ do { return null; } while (1 == 2); }");
|
| + }
|
| +
|
| + void test_doStatement_throwCondition() {
|
| + _assertTrue("{ do {} while (throw ''); }");
|
| + }
|
| +
|
| void test_doStatement_true_break() {
|
| _assertFalse("{ do { break; } while (true); }");
|
| }
|
| @@ -3521,7 +3558,6 @@ class ExitDetectorTest extends ParserTestCase {
|
| _assertTrue("{ x: do { continue x; } while (true); }");
|
| }
|
|
|
| -
|
| void test_doStatement_true_if_return() {
|
| _assertTrue("{ do { if (true) {return null;} } while (true); }");
|
| }
|
| @@ -3924,6 +3960,10 @@ on String catch (e, s) { return 1; }''');
|
| _assertFalse("{ while (true) { break; } }");
|
| }
|
|
|
| + void test_whileStatement_true_break_and_throw() {
|
| + _assertFalse("{ while (true) { if (1==1) break; throw 'T'; } }");
|
| + }
|
| +
|
| void test_whileStatement_true_continue() {
|
| _assertTrue("{ while (true) { continue; } }");
|
| }
|
| @@ -3952,10 +3992,6 @@ on String catch (e, s) { return 1; }''');
|
| _assertTrue("{ while (true) { throw ''; } }");
|
| }
|
|
|
| - void test_whileStatement_true_break_and_throw() {
|
| - _assertFalse("{ while (true) { if (1==1) break; throw 'T'; } }");
|
| - }
|
| -
|
| void _assertFalse(String source) {
|
| _assertHasReturn(false, source);
|
| }
|
| @@ -4085,32 +4121,32 @@ void f() {
|
| _assertNthStatementDoesNotExit(source, 0);
|
| }
|
|
|
| - void test_whileStatement_switchWithBreakWithLabel() {
|
| + void test_whileStatement_breakWithLabel_afterExting() {
|
| Source source = addSource(r'''
|
| void f() {
|
| x: while (true) {
|
| - switch (true) {
|
| - case false: break;
|
| - case true: break x;
|
| + return;
|
| + if (1 < 2) {
|
| + break x;
|
| }
|
| }
|
| }
|
| ''');
|
| - _assertNthStatementDoesNotExit(source, 0);
|
| + _assertNthStatementExits(source, 0);
|
| }
|
|
|
| - void test_whileStatement_breakWithLabel_afterExting() {
|
| + void test_whileStatement_switchWithBreakWithLabel() {
|
| Source source = addSource(r'''
|
| void f() {
|
| x: while (true) {
|
| - return;
|
| - if (1 < 2) {
|
| - break x;
|
| + switch (true) {
|
| + case false: break;
|
| + case true: break x;
|
| }
|
| }
|
| }
|
| ''');
|
| - _assertNthStatementExits(source, 0);
|
| + _assertNthStatementDoesNotExit(source, 0);
|
| }
|
|
|
| void test_yieldStatement_plain() {
|
|
|