| Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
|
| diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
|
| index 8b1e4dd45c46111d0f37b176df389705e0e567cc..367d5b6313ffdc1e05f1f3adc34559751a221e0d 100644
|
| --- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
|
| +++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
|
| @@ -642,14 +642,17 @@ class ResynthTest extends ResolverTestCase {
|
| }
|
| }
|
|
|
| - void compareExecutableElements(ExecutableElement resynthesized,
|
| - ExecutableElement original, String desc) {
|
| + void compareExecutableElements(
|
| + ExecutableElement resynthesized, ExecutableElement original, String desc,
|
| + {bool shallow: false}) {
|
| compareElements(resynthesized, original, desc);
|
| compareParameterElementLists(
|
| resynthesized.parameters, original.parameters, desc);
|
| compareTypes(
|
| resynthesized.returnType, original.returnType, '$desc return type');
|
| - compareTypes(resynthesized.type, original.type, desc);
|
| + if (!shallow) {
|
| + compareTypes(resynthesized.type, original.type, desc);
|
| + }
|
| expect(resynthesized.typeParameters.length, original.typeParameters.length);
|
| for (int i = 0; i < resynthesized.typeParameters.length; i++) {
|
| compareTypeParameterElements(
|
| @@ -704,12 +707,13 @@ class ResynthTest extends ResolverTestCase {
|
| }
|
|
|
| void compareFunctionElements(
|
| - FunctionElement resynthesized, FunctionElement original, String desc) {
|
| + FunctionElement resynthesized, FunctionElement original, String desc,
|
| + {bool shallow: false}) {
|
| if (original == null && resynthesized == null) {
|
| return;
|
| }
|
| expect(resynthesized, isNotNull, reason: desc);
|
| - compareExecutableElements(resynthesized, original, desc);
|
| + compareExecutableElements(resynthesized, original, desc, shallow: shallow);
|
| checkPossibleLocalElements(resynthesized, original);
|
| }
|
|
|
| @@ -937,6 +941,15 @@ class ResynthTest extends ResolverTestCase {
|
| compareFunctionTypeAliasElements(
|
| resynthesized.element, original.element, desc);
|
| }
|
| + if (original.element.enclosingElement == null &&
|
| + original.element is FunctionElement) {
|
| + expect(resynthesized.element, new isInstanceOf<FunctionElement>());
|
| + expect(resynthesized.element.enclosingElement, isNull, reason: desc);
|
| + compareFunctionElements(
|
| + resynthesized.element, original.element, '$desc element',
|
| + shallow: true);
|
| + expect(resynthesized.element.type, same(resynthesized));
|
| + }
|
| expect(resynthesized.typeArguments.length, original.typeArguments.length,
|
| reason: desc);
|
| for (int i = 0; i < resynthesized.typeArguments.length; i++) {
|
| @@ -993,8 +1006,8 @@ class ResynthTest extends ResolverTestCase {
|
| VariableElementImpl resynthesizedActual =
|
| getActualElement(resynthesized, desc);
|
| VariableElementImpl originalActual = getActualElement(original, desc);
|
| - compareFunctionElements(
|
| - resynthesizedActual.initializer, originalActual.initializer, desc);
|
| + compareFunctionElements(resynthesizedActual.initializer,
|
| + originalActual.initializer, '$desc initializer');
|
| if (originalActual is ConstVariableElement) {
|
| Element oEnclosing = original.enclosingElement;
|
| if (oEnclosing is ClassElement && oEnclosing.isEnum) {
|
| @@ -3632,6 +3645,70 @@ void set x(value) {}''');
|
| checkLibrary('void set x(int value) {} set y(value) {}');
|
| }
|
|
|
| + test_syntheticFunctionType_genericClosure() {
|
| + if (!options.strongMode) {
|
| + // The test below uses generic comment syntax because proper generic
|
| + // method syntax doesn't support generic closures. So it can only run in
|
| + // strong mode.
|
| + // TODO(paulberry): once proper generic method syntax supports generic
|
| + // closures, rewrite the test below without using generic comment syntax,
|
| + // and remove this hack. See dartbug.com/25819
|
| + return;
|
| + }
|
| + checkLibrary('''
|
| +final v = f() ? /*<T>*/(T t) => 0 : /*<T>*/(T t) => 1;
|
| +bool f() => true;
|
| +''');
|
| + }
|
| +
|
| + test_syntheticFunctionType_genericClosure_inGenericFunction() {
|
| + if (!options.strongMode) {
|
| + // The test below uses generic comment syntax because proper generic
|
| + // method syntax doesn't support generic closures. So it can only run in
|
| + // strong mode.
|
| + // TODO(paulberry): once proper generic method syntax supports generic
|
| + // closures, rewrite the test below without using generic comment syntax,
|
| + // and remove this hack. See dartbug.com/25819
|
| + return;
|
| + }
|
| + checkLibrary('''
|
| +void f<T, U>(bool b) {
|
| + final v = b ? /*<V>*/(T t, U u, V v) => 0 : /*<V>*/(T t, U u, V v) => 1;
|
| +}
|
| +''');
|
| + }
|
| +
|
| + test_syntheticFunctionType_inGenericClass() {
|
| + checkLibrary('''
|
| +class C<T, U> {
|
| + var v = f() ? (T t, U u) => 0 : (T t, U u) => 1;
|
| +}
|
| +bool f() => false;
|
| +''');
|
| + }
|
| +
|
| + test_syntheticFunctionType_inGenericFunction() {
|
| + checkLibrary('''
|
| +void f<T, U>(bool b) {
|
| + var v = b ? (T t, U u) => 0 : (T t, U u) => 1;
|
| +}
|
| +''');
|
| + }
|
| +
|
| + test_syntheticFunctionType_noArguments() {
|
| + checkLibrary('''
|
| +final v = f() ? () => 0 : () => 1;
|
| +bool f() => true;
|
| +''');
|
| + }
|
| +
|
| + test_syntheticFunctionType_withArguments() {
|
| + checkLibrary('''
|
| +final v = f() ? (int x, String y) => 0 : (int x, String y) => 1;
|
| +bool f() => true;
|
| +''');
|
| + }
|
| +
|
| test_type_arguments_explicit_dynamic_dynamic() {
|
| checkLibrary('Map<dynamic, dynamic> m;');
|
| }
|
|
|