OLD | NEW |
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 analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 UnlinkedClass cls = serializeClassText(''' | 1836 UnlinkedClass cls = serializeClassText(''' |
1837 class C<T> { | 1837 class C<T> { |
1838 final x; | 1838 final x; |
1839 const C(T) : x = T; | 1839 const C(T) : x = T; |
1840 } | 1840 } |
1841 '''); | 1841 '''); |
1842 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, | 1842 _assertUnlinkedConst(cls.executables[0].constantInitializers[0].expression, |
1843 operators: [UnlinkedExprOperation.pushParameter], strings: ['T']); | 1843 operators: [UnlinkedExprOperation.pushParameter], strings: ['T']); |
1844 } | 1844 } |
1845 | 1845 |
| 1846 test_constExpr_functionExpression() { |
| 1847 if (skipNonConstInitializers) { |
| 1848 return; |
| 1849 } |
| 1850 UnlinkedVariable variable = serializeVariableText(''' |
| 1851 import 'dart:async'; |
| 1852 const v = (f) async => await f; |
| 1853 '''); |
| 1854 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 1855 isValidConst: false, |
| 1856 operators: [ |
| 1857 UnlinkedExprOperation.pushParameter, |
| 1858 UnlinkedExprOperation.await |
| 1859 ], |
| 1860 strings: [ |
| 1861 'f' |
| 1862 ], |
| 1863 ints: []); |
| 1864 } |
| 1865 |
1846 test_constExpr_functionExpression_asArgument() { | 1866 test_constExpr_functionExpression_asArgument() { |
1847 // Even though function expressions are not allowed in constant | 1867 // Even though function expressions are not allowed in constant |
1848 // declarations, they might occur due to erroneous code, so make sure they | 1868 // declarations, they might occur due to erroneous code, so make sure they |
1849 // function correctly. | 1869 // function correctly. |
1850 UnlinkedVariable variable = serializeVariableText(''' | 1870 UnlinkedVariable variable = serializeVariableText(''' |
1851 const v = foo(5, () => 42); | 1871 const v = foo(5, () => 42); |
1852 foo(a, b) {} | 1872 foo(a, b) {} |
1853 '''); | 1873 '''); |
1854 _assertUnlinkedConst(variable.initializer.bodyExpr, | 1874 _assertUnlinkedConst(variable.initializer.bodyExpr, |
1855 isValidConst: false, | 1875 isValidConst: false, |
(...skipping 8516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10372 class _PrefixExpectation { | 10392 class _PrefixExpectation { |
10373 final ReferenceKind kind; | 10393 final ReferenceKind kind; |
10374 final String name; | 10394 final String name; |
10375 final String absoluteUri; | 10395 final String absoluteUri; |
10376 final String relativeUri; | 10396 final String relativeUri; |
10377 final int numTypeParameters; | 10397 final int numTypeParameters; |
10378 | 10398 |
10379 _PrefixExpectation(this.kind, this.name, | 10399 _PrefixExpectation(this.kind, this.name, |
10380 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10400 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
10381 } | 10401 } |
OLD | NEW |