| 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 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 } | 1109 } |
| 1110 checkPossibleMember(resynthesized, original, desc); | 1110 checkPossibleMember(resynthesized, original, desc); |
| 1111 checkPossibleLocalElements(resynthesized, original); | 1111 checkPossibleLocalElements(resynthesized, original); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; | 1114 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; |
| 1115 | 1115 |
| 1116 /** | 1116 /** |
| 1117 * Determine the analysis options that should be used for this test. | 1117 * Determine the analysis options that should be used for this test. |
| 1118 */ | 1118 */ |
| 1119 AnalysisOptionsImpl createOptions() => | 1119 AnalysisOptionsImpl createOptions() => new AnalysisOptionsImpl(); |
| 1120 new AnalysisOptionsImpl()..enableGenericMethods = true; | |
| 1121 | 1120 |
| 1122 ElementImpl getActualElement(Element element, String desc) { | 1121 ElementImpl getActualElement(Element element, String desc) { |
| 1123 if (element == null) { | 1122 if (element == null) { |
| 1124 return null; | 1123 return null; |
| 1125 } else if (element is ElementImpl) { | 1124 } else if (element is ElementImpl) { |
| 1126 return element; | 1125 return element; |
| 1127 } else if (element is ElementHandle) { | 1126 } else if (element is ElementHandle) { |
| 1128 Element actualElement = element.actualElement; | 1127 Element actualElement = element.actualElement; |
| 1129 // A handle should never point to a member, because if it did, then | 1128 // A handle should never point to a member, because if it did, then |
| 1130 // "is Member" checks on the handle would produce the wrong result. | 1129 // "is Member" checks on the handle would produce the wrong result. |
| (...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3193 | 3192 |
| 3194 test_function_return_type_implicit() { | 3193 test_function_return_type_implicit() { |
| 3195 checkLibrary('f() => null;'); | 3194 checkLibrary('f() => null;'); |
| 3196 } | 3195 } |
| 3197 | 3196 |
| 3198 test_function_return_type_void() { | 3197 test_function_return_type_void() { |
| 3199 checkLibrary('void f() {}'); | 3198 checkLibrary('void f() {}'); |
| 3200 } | 3199 } |
| 3201 | 3200 |
| 3202 test_function_type_parameter() { | 3201 test_function_type_parameter() { |
| 3203 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 3202 prepareAnalysisContext(createOptions()); |
| 3204 checkLibrary('T f<T, U>(U u) => null;'); | 3203 checkLibrary('T f<T, U>(U u) => null;'); |
| 3205 } | 3204 } |
| 3206 | 3205 |
| 3207 test_function_type_parameter_with_function_typed_parameter() { | 3206 test_function_type_parameter_with_function_typed_parameter() { |
| 3208 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 3207 prepareAnalysisContext(createOptions()); |
| 3209 checkLibrary('void f<T, U>(T x(U u)) {}'); | 3208 checkLibrary('void f<T, U>(T x(U u)) {}'); |
| 3210 } | 3209 } |
| 3211 | 3210 |
| 3212 test_functions() { | 3211 test_functions() { |
| 3213 checkLibrary('f() {} g() {}'); | 3212 checkLibrary('f() {} g() {}'); |
| 3214 } | 3213 } |
| 3215 | 3214 |
| 3216 test_generic_gClass_gMethodStatic() { | 3215 test_generic_gClass_gMethodStatic() { |
| 3217 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 3216 prepareAnalysisContext(createOptions()); |
| 3218 checkLibrary(''' | 3217 checkLibrary(''' |
| 3219 class C<T, U> { | 3218 class C<T, U> { |
| 3220 static void m<V, W>(V v, W w) { | 3219 static void m<V, W>(V v, W w) { |
| 3221 void f<X, Y>(V v, W w, X x, Y y) { | 3220 void f<X, Y>(V v, W w, X x, Y y) { |
| 3222 } | 3221 } |
| 3223 } | 3222 } |
| 3224 } | 3223 } |
| 3225 '''); | 3224 '''); |
| 3226 } | 3225 } |
| 3227 | 3226 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4028 | 4027 |
| 4029 test_method_parameter_return_type() { | 4028 test_method_parameter_return_type() { |
| 4030 checkLibrary('class C { f(int g()) {} }'); | 4029 checkLibrary('class C { f(int g()) {} }'); |
| 4031 } | 4030 } |
| 4032 | 4031 |
| 4033 test_method_parameter_return_type_void() { | 4032 test_method_parameter_return_type_void() { |
| 4034 checkLibrary('class C { f(void g()) {} }'); | 4033 checkLibrary('class C { f(void g()) {} }'); |
| 4035 } | 4034 } |
| 4036 | 4035 |
| 4037 test_method_type_parameter() { | 4036 test_method_type_parameter() { |
| 4038 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 4037 prepareAnalysisContext(createOptions()); |
| 4039 checkLibrary('class C { T f<T, U>(U u) => null; }'); | 4038 checkLibrary('class C { T f<T, U>(U u) => null; }'); |
| 4040 } | 4039 } |
| 4041 | 4040 |
| 4042 test_method_type_parameter_in_generic_class() { | 4041 test_method_type_parameter_in_generic_class() { |
| 4043 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 4042 prepareAnalysisContext(createOptions()); |
| 4044 checkLibrary('class C<T, U> { V f<V, W>(T t, U u, W w) => null; }'); | 4043 checkLibrary('class C<T, U> { V f<V, W>(T t, U u, W w) => null; }'); |
| 4045 } | 4044 } |
| 4046 | 4045 |
| 4047 test_method_type_parameter_with_function_typed_parameter() { | 4046 test_method_type_parameter_with_function_typed_parameter() { |
| 4048 prepareAnalysisContext(createOptions()..enableGenericMethods = true); | 4047 prepareAnalysisContext(createOptions()); |
| 4049 checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); | 4048 checkLibrary('class C { void f<T, U>(T x(U u)) {} }'); |
| 4050 } | 4049 } |
| 4051 | 4050 |
| 4052 test_nested_generic_functions_in_generic_class_with_function_typed_params() { | 4051 test_nested_generic_functions_in_generic_class_with_function_typed_params() { |
| 4053 checkLibrary(''' | 4052 checkLibrary(''' |
| 4054 class C<T, U> { | 4053 class C<T, U> { |
| 4055 void g<V, W>() { | 4054 void g<V, W>() { |
| 4056 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { | 4055 void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) { |
| 4057 } | 4056 } |
| 4058 } | 4057 } |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4705 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4704 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 4706 } | 4705 } |
| 4707 return serializedUnit; | 4706 return serializedUnit; |
| 4708 } | 4707 } |
| 4709 | 4708 |
| 4710 @override | 4709 @override |
| 4711 bool hasLibrarySummary(String uri) { | 4710 bool hasLibrarySummary(String uri) { |
| 4712 return true; | 4711 return true; |
| 4713 } | 4712 } |
| 4714 } | 4713 } |
| OLD | NEW |