| Index: tests/compiler/dart2js/type_checker_test.dart
|
| diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
|
| index fb14e82cd588e65865cdae3ba5bb4edf5d5de9e8..9ef843ffccf24a0f2e0eeb0cd3e46ee246899e72 100644
|
| --- a/tests/compiler/dart2js/type_checker_test.dart
|
| +++ b/tests/compiler/dart2js/type_checker_test.dart
|
| @@ -58,7 +58,8 @@ main() {
|
| testTypeLiteral,
|
| testInitializers,
|
| testTypePromotionHints,
|
| - testFunctionCall];
|
| + testFunctionCall,
|
| + testCascade];
|
| for (Function test in tests) {
|
| setup();
|
| test();
|
| @@ -1716,6 +1717,172 @@ testTypePromotionHints() {
|
| infos: []);
|
| }
|
|
|
| +void testCascade() {
|
| + compiler.parseScript(r'''typedef A AFunc();
|
| + typedef Function FuncFunc();
|
| + class A {
|
| + A a;
|
| + B b;
|
| + C c;
|
| + AFunc afunc() => null;
|
| + FuncFunc funcfunc() => null;
|
| + C operator [](_) => null;
|
| + void operator []=(_, C c) {}
|
| + }
|
| + class B {
|
| + B b;
|
| + C c;
|
| + }
|
| + class C {
|
| + C c;
|
| + AFunc afunc() => null;
|
| + }
|
| + ''');
|
| +
|
| + check(String text, {warnings, hints, infos}) {
|
| + analyze('{ $text }', warnings: warnings, hints: hints, infos: infos);
|
| + }
|
| +
|
| + check('A a = new A()..a;');
|
| +
|
| + check('A a = new A()..b;');
|
| +
|
| + check('A a = new A()..a..b;');
|
| +
|
| + check('A a = new A()..b..c..a;');
|
| +
|
| + check('B b = new A()..a;',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('B b = new A()..b;',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('B b = new A().b;');
|
| +
|
| + check('new A().b..b;');
|
| +
|
| + check('new A().b..a;',
|
| + warnings: MEMBER_NOT_FOUND);
|
| +
|
| + check('B b = new A().b..c;');
|
| +
|
| + check('C c = new A().b..c;',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..a = new A();');
|
| +
|
| + check('A a = new A()..b = new B();');
|
| +
|
| + check('B b = new A()..b = new B();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..b = new A();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('AFunc a = new C().afunc();');
|
| +
|
| + check('AFunc a = new C()..afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('C c = new C()..afunc();');
|
| +
|
| + check('A a = new C().afunc()();');
|
| +
|
| + check('A a = new C()..afunc()();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('AFunc a = new C()..afunc()();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| +
|
| + check('FuncFunc f = new A().funcfunc();');
|
| +
|
| + check('A a = new A().funcfunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('FuncFunc f = new A()..funcfunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..funcfunc();');
|
| +
|
| + check('FuncFunc f = new A()..funcfunc()();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..funcfunc()();');
|
| +
|
| + check('FuncFunc f = new A()..funcfunc()()();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..funcfunc()()();');
|
| +
|
| +
|
| + check('''A a;
|
| + a = new A()..a = a = new A()..c.afunc();''');
|
| +
|
| + check('''A a = new A()..b = new B()..c.afunc();''');
|
| +
|
| + check('''A a = new A()..b = new A()..c.afunc();''',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('''A a = new A()..b = new A()..c.afunc()();''',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('''A a = new A()..b = new A()..c.afunc()().b;''',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A().afunc()()[0].afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('C c = new A().afunc()()[0].afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('AFunc a = new A().afunc()()[0].afunc();');
|
| +
|
| + check('A a = new A()..afunc()()[0].afunc();');
|
| +
|
| + check('C c = new A()..afunc()()[0].afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('AFunc a = new A()..afunc()()[0].afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A().afunc()()[0]..afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('C c = new A().afunc()()[0]..afunc();');
|
| +
|
| + check('AFunc a = new A().afunc()()[0]..afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('A a = new A()..afunc()()[0]..afunc();');
|
| +
|
| + check('C c = new A()..afunc()()[0]..afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('AFunc a = new A()..afunc()()[0]..afunc();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('new A()[0] = new A();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('new A()[0] = new C();');
|
| +
|
| + check('new A().a[0] = new A();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('new A().a[0] = new C();');
|
| +
|
| + check('new A()..a[0] = new A();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('new A()..a[0] = new C();');
|
| +
|
| + check('new A()..afunc()()[0] = new A();',
|
| + warnings: NOT_ASSIGNABLE);
|
| +
|
| + check('new A()..afunc()()[0] = new C();');
|
| +}
|
| +
|
| const CLASS_WITH_METHODS = '''
|
| typedef int String2Int(String s);
|
|
|
|
|