| 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 test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2866 addLibrary('dart:async'); | 2866 addLibrary('dart:async'); |
| 2867 checkLibrary('import "dart:async" show Future, Stream; Future f;'); | 2867 checkLibrary('import "dart:async" show Future, Stream; Future f;'); |
| 2868 } | 2868 } |
| 2869 | 2869 |
| 2870 test_imports() { | 2870 test_imports() { |
| 2871 addLibrarySource('/a.dart', 'library a; class C {}'); | 2871 addLibrarySource('/a.dart', 'library a; class C {}'); |
| 2872 addLibrarySource('/b.dart', 'library b; class D {}'); | 2872 addLibrarySource('/b.dart', 'library b; class D {}'); |
| 2873 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); | 2873 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); |
| 2874 } | 2874 } |
| 2875 | 2875 |
| 2876 test_inferred_function_type_for_variable_in_generic_function() { |
| 2877 // In the code below, `x` has an inferred type of `() => int`, with 2 |
| 2878 // (unused) type parameters from the enclosing top level function. |
| 2879 checkLibrary(''' |
| 2880 f<U, V>() { |
| 2881 var x = () => 0; |
| 2882 } |
| 2883 '''); |
| 2884 } |
| 2885 |
| 2886 test_inferred_function_type_in_generic_class_constructor() { |
| 2887 // In the code below, `() => () => 0` has an inferred return type of |
| 2888 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 2889 checkLibrary(''' |
| 2890 class C<U, V> { |
| 2891 final x; |
| 2892 C() : x = (() => () => 0); |
| 2893 } |
| 2894 '''); |
| 2895 } |
| 2896 |
| 2897 test_inferred_function_type_in_generic_class_getter() { |
| 2898 // In the code below, `() => () => 0` has an inferred return type of |
| 2899 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 2900 checkLibrary(''' |
| 2901 class C<U, V> { |
| 2902 get x => () => () => 0; |
| 2903 } |
| 2904 '''); |
| 2905 } |
| 2906 |
| 2907 test_inferred_function_type_in_generic_class_in_generic_method() { |
| 2908 // In the code below, `() => () => 0` has an inferred return type of |
| 2909 // `() => int`, with 3 (unused) type parameters from the enclosing class |
| 2910 // and method. |
| 2911 checkLibrary(''' |
| 2912 class C<T> { |
| 2913 f<U, V>() { |
| 2914 print(() => () => 0); |
| 2915 } |
| 2916 } |
| 2917 '''); |
| 2918 } |
| 2919 |
| 2920 test_inferred_function_type_in_generic_class_setter() { |
| 2921 // In the code below, `() => () => 0` has an inferred return type of |
| 2922 // `() => int`, with 2 (unused) type parameters from the enclosing class. |
| 2923 checkLibrary(''' |
| 2924 class C<U, V> { |
| 2925 void set x(value) { |
| 2926 print(() => () => 0); |
| 2927 } |
| 2928 } |
| 2929 '''); |
| 2930 } |
| 2931 |
| 2876 test_inferred_type_is_typedef() { | 2932 test_inferred_type_is_typedef() { |
| 2877 checkLibrary('typedef int F(String s);' | 2933 checkLibrary('typedef int F(String s);' |
| 2878 ' class C extends D { var v; }' | 2934 ' class C extends D { var v; }' |
| 2879 ' abstract class D { F get v; }'); | 2935 ' abstract class D { F get v; }'); |
| 2880 } | 2936 } |
| 2881 | 2937 |
| 2882 test_inferred_type_refers_to_bound_type_param() { | 2938 test_inferred_type_refers_to_bound_type_param() { |
| 2883 checkLibrary('class C<T> extends D<int, T> { var v; }' | 2939 checkLibrary('class C<T> extends D<int, T> { var v; }' |
| 2884 ' abstract class D<U, V> { Map<V, U> get v; }'); | 2940 ' abstract class D<U, V> { Map<V, U> get v; }'); |
| 2885 } | 2941 } |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3857 fail('Unexpectedly tried to get unlinked summary for $uri'); | 3913 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 3858 } | 3914 } |
| 3859 return serializedUnit; | 3915 return serializedUnit; |
| 3860 } | 3916 } |
| 3861 | 3917 |
| 3862 @override | 3918 @override |
| 3863 bool hasLibrarySummary(String uri) { | 3919 bool hasLibrarySummary(String uri) { |
| 3864 return true; | 3920 return true; |
| 3865 } | 3921 } |
| 3866 } | 3922 } |
| OLD | NEW |