Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1569923002: Fix some corner cases of resynthesizing generic function types. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
9 import 'package:analyzer/src/summary/base.dart'; 10 import 'package:analyzer/src/summary/base.dart';
10 import 'package:analyzer/src/summary/format.dart'; 11 import 'package:analyzer/src/summary/format.dart';
11 import 'package:analyzer/src/summary/resynthesize.dart'; 12 import 'package:analyzer/src/summary/resynthesize.dart';
12 import 'package:analyzer/src/summary/summarize_elements.dart'; 13 import 'package:analyzer/src/summary/summarize_elements.dart';
13 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
14 15
15 import '../../generated/resolver_test.dart'; 16 import '../../generated/resolver_test.dart';
16 import '../../reflective_tests.dart'; 17 import '../../reflective_tests.dart';
17 18
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 compareTypeImpls(resynthesized, original, desc); 391 compareTypeImpls(resynthesized, original, desc);
391 } else if (resynthesized is DynamicTypeImpl && 392 } else if (resynthesized is DynamicTypeImpl &&
392 original is DynamicTypeImpl) { 393 original is DynamicTypeImpl) {
393 expect(resynthesized, same(original)); 394 expect(resynthesized, same(original));
394 } else if (resynthesized is UndefinedTypeImpl && 395 } else if (resynthesized is UndefinedTypeImpl &&
395 original is UndefinedTypeImpl) { 396 original is UndefinedTypeImpl) {
396 expect(resynthesized, same(original)); 397 expect(resynthesized, same(original));
397 } else if (resynthesized is FunctionTypeImpl && 398 } else if (resynthesized is FunctionTypeImpl &&
398 original is FunctionTypeImpl) { 399 original is FunctionTypeImpl) {
399 compareTypeImpls(resynthesized, original, desc); 400 compareTypeImpls(resynthesized, original, desc);
401 expect(resynthesized.isInstantiated, original.isInstantiated,
402 reason: desc);
400 if (original.element.isSynthetic && 403 if (original.element.isSynthetic &&
401 original.element is FunctionTypeAliasElementImpl && 404 original.element is FunctionTypeAliasElementImpl &&
402 resynthesized.element is FunctionTypeAliasElementImpl) { 405 resynthesized.element is FunctionTypeAliasElementImpl) {
403 compareFunctionTypeAliasElements( 406 compareFunctionTypeAliasElements(
404 resynthesized.element, original.element, desc); 407 resynthesized.element, original.element, desc);
405 } 408 }
406 expect(resynthesized.typeArguments.length, original.typeArguments.length, 409 expect(resynthesized.typeArguments.length, original.typeArguments.length,
407 reason: desc); 410 reason: desc);
408 for (int i = 0; i < resynthesized.typeArguments.length; i++) { 411 for (int i = 0; i < resynthesized.typeArguments.length; i++) {
409 compareTypes(resynthesized.typeArguments[i], original.typeArguments[i], 412 compareTypes(resynthesized.typeArguments[i], original.typeArguments[i],
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 802 }
800 803
801 test_function_return_type_implicit() { 804 test_function_return_type_implicit() {
802 checkLibrary('f() => null;'); 805 checkLibrary('f() => null;');
803 } 806 }
804 807
805 test_function_return_type_void() { 808 test_function_return_type_void() {
806 checkLibrary('void f() {}'); 809 checkLibrary('void f() {}');
807 } 810 }
808 811
812 test_function_type_parameter() {
813 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
814 checkLibrary('T f<T, U>(U u) => null;');
815 }
816
817 test_function_type_parameter_with_function_typed_parameter() {
818 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
819 checkLibrary('void f<T, U>(T x(U u)) {}');
820 }
821
809 test_functions() { 822 test_functions() {
810 checkLibrary('f() {} g() {}'); 823 checkLibrary('f() {} g() {}');
811 } 824 }
812 825
813 test_getter_external() { 826 test_getter_external() {
814 checkLibrary('external int get x;'); 827 checkLibrary('external int get x;');
815 } 828 }
816 829
817 test_getters() { 830 test_getters() {
818 checkLibrary('int get x => null; get y => null;'); 831 checkLibrary('int get x => null; get y => null;');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 874 }
862 875
863 test_method_parameter_return_type() { 876 test_method_parameter_return_type() {
864 checkLibrary('class C { f(int g()) {} }'); 877 checkLibrary('class C { f(int g()) {} }');
865 } 878 }
866 879
867 test_method_parameter_return_type_void() { 880 test_method_parameter_return_type_void() {
868 checkLibrary('class C { f(void g()) {} }'); 881 checkLibrary('class C { f(void g()) {} }');
869 } 882 }
870 883
884 test_method_type_parameter() {
885 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
886 checkLibrary('class C { T f<T, U>(U u) => null; }');
887 }
888
889 test_method_type_parameter_in_generic_class() {
890 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
891 checkLibrary('class C<T, U> { V f<V, W>(T t, U u, W w) => null; }');
892 }
893
894 test_method_type_parameter_with_function_typed_parameter() {
895 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
896 checkLibrary('class C { void f<T, U>(T x(U u)) {} }');
897 }
898
871 test_operator() { 899 test_operator() {
872 checkLibrary('class C { C operator+(C other) => null; }'); 900 checkLibrary('class C { C operator+(C other) => null; }');
873 } 901 }
874 902
875 test_operator_equal() { 903 test_operator_equal() {
876 checkLibrary('class C { bool operator==(C other) => false; }'); 904 checkLibrary('class C { bool operator==(C other) => false; }');
877 } 905 }
878 906
879 test_operator_external() { 907 test_operator_external() {
880 checkLibrary('class C { external C operator+(C other); }'); 908 checkLibrary('class C { external C operator+(C other); }');
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } 1137 }
1110 1138
1111 test_variable_implicit_type() { 1139 test_variable_implicit_type() {
1112 checkLibrary('var x;'); 1140 checkLibrary('var x;');
1113 } 1141 }
1114 1142
1115 test_variables() { 1143 test_variables() {
1116 checkLibrary('int i; int j;'); 1144 checkLibrary('int i; int j;');
1117 } 1145 }
1118 } 1146 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698