| 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/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/dart/element/element.dart'; | 9 import 'package:analyzer/src/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/element/type.dart'; | 10 import 'package:analyzer/src/dart/element/type.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 main() { | 24 main() { |
| 25 groupSep = ' | '; | 25 groupSep = ' | '; |
| 26 runReflectiveTests(ResynthTest); | 26 runReflectiveTests(ResynthTest); |
| 27 } | 27 } |
| 28 | 28 |
| 29 @reflectiveTest | 29 @reflectiveTest |
| 30 class ResynthTest extends ResolverTestCase { | 30 class ResynthTest extends ResolverTestCase { |
| 31 Set<Source> otherLibrarySources = new Set<Source>(); | 31 Set<Source> otherLibrarySources = new Set<Source>(); |
| 32 | 32 |
| 33 @override | |
| 34 void setUp() { | |
| 35 super.setUp(); | |
| 36 resetWithOptions(options); | |
| 37 } | |
| 38 | |
| 39 /** | 33 /** |
| 40 * Determine the analysis options that should be used for this test. | 34 * Determine the analysis options that should be used for this test. |
| 41 */ | 35 */ |
| 42 AnalysisOptionsImpl get options => | 36 AnalysisOptionsImpl get options => |
| 43 new AnalysisOptionsImpl()..enableGenericMethods = true; | 37 new AnalysisOptionsImpl()..enableGenericMethods = true; |
| 44 | 38 |
| 45 void addLibrary(String uri) { | 39 void addLibrary(String uri) { |
| 46 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri)); | 40 otherLibrarySources.add(analysisContext2.sourceFactory.forUri(uri)); |
| 47 } | 41 } |
| 48 | 42 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 538 } |
| 545 String uri = source.uri.toString(); | 539 String uri = source.uri.toString(); |
| 546 addLibrary('dart:core'); | 540 addLibrary('dart:core'); |
| 547 return resynthesizeLibraryElement(uri, original); | 541 return resynthesizeLibraryElement(uri, original); |
| 548 } | 542 } |
| 549 | 543 |
| 550 LibraryElementImpl resynthesizeLibraryElement( | 544 LibraryElementImpl resynthesizeLibraryElement( |
| 551 String uri, LibraryElementImpl original) { | 545 String uri, LibraryElementImpl original) { |
| 552 Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{}; | 546 Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{}; |
| 553 LinkedLibrary getLinkedSummaryFor(LibraryElement lib) { | 547 LinkedLibrary getLinkedSummaryFor(LibraryElement lib) { |
| 554 LibrarySerializationResult serialized = | 548 LibrarySerializationResult serialized = serializeLibrary( |
| 555 serializeLibrary(lib, typeProvider); | 549 lib, typeProvider, analysisContext.analysisOptions.strongMode); |
| 556 for (int i = 0; i < serialized.unlinkedUnits.length; i++) { | 550 for (int i = 0; i < serialized.unlinkedUnits.length; i++) { |
| 557 unlinkedSummaries[serialized.unitUris[i]] = | 551 unlinkedSummaries[serialized.unitUris[i]] = |
| 558 new UnlinkedUnit.fromBuffer(serialized.unlinkedUnits[i].toBuffer()); | 552 new UnlinkedUnit.fromBuffer(serialized.unlinkedUnits[i].toBuffer()); |
| 559 } | 553 } |
| 560 return new LinkedLibrary.fromBuffer(serialized.linked.toBuffer()); | 554 return new LinkedLibrary.fromBuffer(serialized.linked.toBuffer()); |
| 561 } | 555 } |
| 562 Map<String, LinkedLibrary> linkedSummaries = <String, LinkedLibrary>{ | 556 Map<String, LinkedLibrary> linkedSummaries = <String, LinkedLibrary>{ |
| 563 uri: getLinkedSummaryFor(original) | 557 uri: getLinkedSummaryFor(original) |
| 564 }; | 558 }; |
| 565 for (Source source in otherLibrarySources) { | 559 for (Source source in otherLibrarySources) { |
| 566 LibraryElement original = resolve2(source); | 560 LibraryElement original = resolve2(source); |
| 567 String uri = source.uri.toString(); | 561 String uri = source.uri.toString(); |
| 568 linkedSummaries[uri] = getLinkedSummaryFor(original); | 562 linkedSummaries[uri] = getLinkedSummaryFor(original); |
| 569 } | 563 } |
| 570 _TestSummaryResynthesizer resynthesizer = new _TestSummaryResynthesizer( | 564 _TestSummaryResynthesizer resynthesizer = new _TestSummaryResynthesizer( |
| 571 null, | 565 null, |
| 572 analysisContext, | 566 analysisContext, |
| 573 analysisContext.typeProvider, | 567 analysisContext.typeProvider, |
| 574 analysisContext.sourceFactory, | 568 analysisContext.sourceFactory, |
| 575 unlinkedSummaries, | 569 unlinkedSummaries, |
| 576 linkedSummaries); | 570 linkedSummaries, |
| 571 options.strongMode); |
| 577 LibraryElementImpl resynthesized = resynthesizer.getLibraryElement(uri); | 572 LibraryElementImpl resynthesized = resynthesizer.getLibraryElement(uri); |
| 578 // Check that no other summaries needed to be resynthesized to resynthesize | 573 // Check that no other summaries needed to be resynthesized to resynthesize |
| 579 // the library element. | 574 // the library element. |
| 580 expect(resynthesizer.resynthesisCount, 1); | 575 expect(resynthesizer.resynthesisCount, 1); |
| 581 return resynthesized; | 576 return resynthesized; |
| 582 } | 577 } |
| 583 | 578 |
| 579 @override |
| 580 void setUp() { |
| 581 super.setUp(); |
| 582 resetWithOptions(options); |
| 583 } |
| 584 |
| 584 test_class_abstract() { | 585 test_class_abstract() { |
| 585 checkLibrary('abstract class C {}'); | 586 checkLibrary('abstract class C {}'); |
| 586 } | 587 } |
| 587 | 588 |
| 588 test_class_alias() { | 589 test_class_alias() { |
| 589 checkLibrary('class C = D with E, F; class D {} class E {} class F {}'); | 590 checkLibrary('class C = D with E, F; class D {} class E {} class F {}'); |
| 590 } | 591 } |
| 591 | 592 |
| 592 test_class_alias_abstract() { | 593 test_class_alias_abstract() { |
| 593 checkLibrary('abstract class C = D with E; class D {} class E {}'); | 594 checkLibrary('abstract class C = D with E; class D {} class E {}'); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 | 852 |
| 852 test_class_setter_external() { | 853 test_class_setter_external() { |
| 853 checkLibrary('class C { external void set x(int value); }'); | 854 checkLibrary('class C { external void set x(int value); }'); |
| 854 } | 855 } |
| 855 | 856 |
| 856 test_class_setter_implicit_param_type() { | 857 test_class_setter_implicit_param_type() { |
| 857 checkLibrary('class C { void set x(value) {} }'); | 858 checkLibrary('class C { void set x(value) {} }'); |
| 858 } | 859 } |
| 859 | 860 |
| 860 test_class_setter_implicit_return_type() { | 861 test_class_setter_implicit_return_type() { |
| 861 if (analysisContext.analysisOptions.strongMode) { | |
| 862 // TODO(paulberry): fix this test in strong mode. | |
| 863 return; | |
| 864 } | |
| 865 checkLibrary('class C { set x(int value) {} }'); | 862 checkLibrary('class C { set x(int value) {} }'); |
| 866 } | 863 } |
| 867 | 864 |
| 868 test_class_setter_static() { | 865 test_class_setter_static() { |
| 869 checkLibrary('class C { static void set x(int value) {} }'); | 866 checkLibrary('class C { static void set x(int value) {} }'); |
| 870 } | 867 } |
| 871 | 868 |
| 872 test_class_setters() { | 869 test_class_setters() { |
| 873 if (analysisContext.analysisOptions.strongMode) { | |
| 874 // TODO(paulberry): fix this test in strong mode. | |
| 875 return; | |
| 876 } | |
| 877 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); | 870 checkLibrary('class C { void set x(int value) {} set y(value) {} }'); |
| 878 } | 871 } |
| 879 | 872 |
| 880 test_class_supertype() { | 873 test_class_supertype() { |
| 881 checkLibrary('class C extends D {} class D {}'); | 874 checkLibrary('class C extends D {} class D {}'); |
| 882 } | 875 } |
| 883 | 876 |
| 884 test_class_type_parameters() { | 877 test_class_type_parameters() { |
| 885 checkLibrary('class C<T, U> {}'); | 878 checkLibrary('class C<T, U> {}'); |
| 886 } | 879 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 test_field_documented() { | 1010 test_field_documented() { |
| 1018 checkLibrary(''' | 1011 checkLibrary(''' |
| 1019 class C { | 1012 class C { |
| 1020 /** | 1013 /** |
| 1021 * Docs | 1014 * Docs |
| 1022 */ | 1015 */ |
| 1023 var x; | 1016 var x; |
| 1024 }'''); | 1017 }'''); |
| 1025 } | 1018 } |
| 1026 | 1019 |
| 1020 test_field_formal_param_inferred_type_implicit() { |
| 1021 checkLibrary('class C extends D { var v; C(this.v); }' |
| 1022 ' abstract class D { int get v; }'); |
| 1023 } |
| 1024 |
| 1025 test_field_inferred_type_nonstatic_explicit_initialized() { |
| 1026 checkLibrary('class C { num v = 0; }'); |
| 1027 } |
| 1028 |
| 1029 test_field_inferred_type_nonstatic_implicit_initialized() { |
| 1030 checkLibrary('class C { var v = 0; }'); |
| 1031 } |
| 1032 |
| 1033 test_field_inferred_type_nonstatic_implicit_uninitialized() { |
| 1034 checkLibrary( |
| 1035 'class C extends D { var v; } abstract class D { int get v; }'); |
| 1036 } |
| 1037 |
| 1038 test_field_inferred_type_static_implicit_initialized() { |
| 1039 checkLibrary('class C { static var v = 0; }'); |
| 1040 } |
| 1041 |
| 1027 test_field_propagatedType_const_noDep() { | 1042 test_field_propagatedType_const_noDep() { |
| 1028 if (analysisContext.analysisOptions.strongMode) { | |
| 1029 // TODO(paulberry): fix this test in strong mode. | |
| 1030 return; | |
| 1031 } | |
| 1032 checkLibrary(''' | 1043 checkLibrary(''' |
| 1033 class C { | 1044 class C { |
| 1034 static const x = 0; | 1045 static const x = 0; |
| 1035 }'''); | 1046 }'''); |
| 1036 } | 1047 } |
| 1037 | 1048 |
| 1038 test_field_propagatedType_final_dep_inLib() { | 1049 test_field_propagatedType_final_dep_inLib() { |
| 1039 if (analysisContext.analysisOptions.strongMode) { | |
| 1040 // TODO(paulberry): fix this test in strong mode. | |
| 1041 return; | |
| 1042 } | |
| 1043 addNamedSource('/a.dart', 'final a = 1;'); | 1050 addNamedSource('/a.dart', 'final a = 1;'); |
| 1044 checkLibrary(''' | 1051 checkLibrary(''' |
| 1045 import "a.dart"; | 1052 import "a.dart"; |
| 1046 class C { | 1053 class C { |
| 1047 final b = a / 2; | 1054 final b = a / 2; |
| 1048 }'''); | 1055 }'''); |
| 1049 } | 1056 } |
| 1050 | 1057 |
| 1051 test_field_propagatedType_final_dep_inPart() { | 1058 test_field_propagatedType_final_dep_inPart() { |
| 1052 if (analysisContext.analysisOptions.strongMode) { | |
| 1053 // TODO(paulberry): fix this test in strong mode. | |
| 1054 return; | |
| 1055 } | |
| 1056 addNamedSource('/a.dart', 'part of lib; final a = 1;'); | 1059 addNamedSource('/a.dart', 'part of lib; final a = 1;'); |
| 1057 checkLibrary(''' | 1060 checkLibrary(''' |
| 1058 library lib; | 1061 library lib; |
| 1059 part "a.dart"; | 1062 part "a.dart"; |
| 1060 class C { | 1063 class C { |
| 1061 final b = a / 2; | 1064 final b = a / 2; |
| 1062 }'''); | 1065 }'''); |
| 1063 } | 1066 } |
| 1064 | 1067 |
| 1065 test_field_propagatedType_final_noDep_instance() { | 1068 test_field_propagatedType_final_noDep_instance() { |
| 1066 if (analysisContext.analysisOptions.strongMode) { | |
| 1067 // TODO(paulberry): fix this test in strong mode. | |
| 1068 return; | |
| 1069 } | |
| 1070 checkLibrary(''' | 1069 checkLibrary(''' |
| 1071 class C { | 1070 class C { |
| 1072 final x = 0; | 1071 final x = 0; |
| 1073 }'''); | 1072 }'''); |
| 1074 } | 1073 } |
| 1075 | 1074 |
| 1076 test_field_propagatedType_final_noDep_static() { | 1075 test_field_propagatedType_final_noDep_static() { |
| 1077 if (analysisContext.analysisOptions.strongMode) { | |
| 1078 // TODO(paulberry): fix this test in strong mode. | |
| 1079 return; | |
| 1080 } | |
| 1081 checkLibrary(''' | 1076 checkLibrary(''' |
| 1082 class C { | 1077 class C { |
| 1083 static final x = 0; | 1078 static final x = 0; |
| 1084 }'''); | 1079 }'''); |
| 1085 } | 1080 } |
| 1086 | 1081 |
| 1087 test_function_documented() { | 1082 test_function_documented() { |
| 1088 checkLibrary(''' | 1083 checkLibrary(''' |
| 1089 // Extra comment so doc comment offset != 0 | 1084 // Extra comment so doc comment offset != 0 |
| 1090 /** | 1085 /** |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 /** | 1177 /** |
| 1183 * Docs | 1178 * Docs |
| 1184 */ | 1179 */ |
| 1185 get x => null;'''); | 1180 get x => null;'''); |
| 1186 } | 1181 } |
| 1187 | 1182 |
| 1188 test_getter_external() { | 1183 test_getter_external() { |
| 1189 checkLibrary('external int get x;'); | 1184 checkLibrary('external int get x;'); |
| 1190 } | 1185 } |
| 1191 | 1186 |
| 1187 test_getter_inferred_type_nonstatic_implicit_return() { |
| 1188 checkLibrary( |
| 1189 'class C extends D { get f => null; } abstract class D { int get f; }'); |
| 1190 } |
| 1191 |
| 1192 test_getters() { | 1192 test_getters() { |
| 1193 checkLibrary('int get x => null; get y => null;'); | 1193 checkLibrary('int get x => null; get y => null;'); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 test_implicitTopLevelVariable_getterFirst() { | 1196 test_implicitTopLevelVariable_getterFirst() { |
| 1197 checkLibrary('int get x => 0; void set x(int value) {}'); | 1197 checkLibrary('int get x => 0; void set x(int value) {}'); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 test_implicitTopLevelVariable_setterFirst() { | 1200 test_implicitTopLevelVariable_setterFirst() { |
| 1201 checkLibrary('void set x(int value) {} int get x => 0;'); | 1201 checkLibrary('void set x(int value) {} int get x => 0;'); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 test_method_documented() { | 1301 test_method_documented() { |
| 1302 checkLibrary(''' | 1302 checkLibrary(''' |
| 1303 class C { | 1303 class C { |
| 1304 /** | 1304 /** |
| 1305 * Docs | 1305 * Docs |
| 1306 */ | 1306 */ |
| 1307 f() {} | 1307 f() {} |
| 1308 }'''); | 1308 }'''); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 test_method_inferred_type_nonstatic_implicit_param() { |
| 1312 checkLibrary('class C extends D { void f(value) {} }' |
| 1313 ' abstract class D { void f(int value); }'); |
| 1314 } |
| 1315 |
| 1316 test_method_inferred_type_nonstatic_implicit_return() { |
| 1317 checkLibrary( |
| 1318 'class C extends D { f() => null; } abstract class D { int f(); }'); |
| 1319 } |
| 1320 |
| 1311 test_method_parameter_parameters() { | 1321 test_method_parameter_parameters() { |
| 1312 checkLibrary('class C { f(g(x, y)) {} }'); | 1322 checkLibrary('class C { f(g(x, y)) {} }'); |
| 1313 } | 1323 } |
| 1314 | 1324 |
| 1315 test_method_parameter_parameters_in_generic_class() { | 1325 test_method_parameter_parameters_in_generic_class() { |
| 1316 checkLibrary('class C<A, B> { f(A g(B x)) {} }'); | 1326 checkLibrary('class C<A, B> { f(A g(B x)) {} }'); |
| 1317 } | 1327 } |
| 1318 | 1328 |
| 1319 test_method_parameter_return_type() { | 1329 test_method_parameter_return_type() { |
| 1320 checkLibrary('class C { f(int g()) {} }'); | 1330 checkLibrary('class C { f(int g()) {} }'); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 /** | 1389 /** |
| 1380 * Docs | 1390 * Docs |
| 1381 */ | 1391 */ |
| 1382 void set x(value) {}'''); | 1392 void set x(value) {}'''); |
| 1383 } | 1393 } |
| 1384 | 1394 |
| 1385 test_setter_external() { | 1395 test_setter_external() { |
| 1386 checkLibrary('external void set x(int value);'); | 1396 checkLibrary('external void set x(int value);'); |
| 1387 } | 1397 } |
| 1388 | 1398 |
| 1399 test_setter_inferred_type_nonstatic_implicit_param() { |
| 1400 checkLibrary('class C extends D { void set f(value) {} }' |
| 1401 ' abstract class D { void set f(int value); }'); |
| 1402 } |
| 1403 |
| 1404 test_setter_inferred_type_static_implicit_return() { |
| 1405 checkLibrary('class C { static set f(int value) {} }'); |
| 1406 } |
| 1407 |
| 1408 test_setter_inferred_type_top_level_implicit_return() { |
| 1409 checkLibrary('set f(int value) {}'); |
| 1410 } |
| 1411 |
| 1389 test_setters() { | 1412 test_setters() { |
| 1390 if (analysisContext.analysisOptions.strongMode) { | |
| 1391 // TODO(paulberry): fix this test in strong mode. | |
| 1392 return; | |
| 1393 } | |
| 1394 checkLibrary('void set x(int value) {} set y(value) {}'); | 1413 checkLibrary('void set x(int value) {} set y(value) {}'); |
| 1395 } | 1414 } |
| 1396 | 1415 |
| 1397 test_type_arguments_explicit_dynamic_dynamic() { | 1416 test_type_arguments_explicit_dynamic_dynamic() { |
| 1398 checkLibrary('Map<dynamic, dynamic> m;'); | 1417 checkLibrary('Map<dynamic, dynamic> m;'); |
| 1399 } | 1418 } |
| 1400 | 1419 |
| 1401 test_type_arguments_explicit_dynamic_int() { | 1420 test_type_arguments_explicit_dynamic_int() { |
| 1402 checkLibrary('Map<dynamic, int> m;'); | 1421 checkLibrary('Map<dynamic, int> m;'); |
| 1403 } | 1422 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 test_variable_getterInPart_setterInPart() { | 1658 test_variable_getterInPart_setterInPart() { |
| 1640 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;'); | 1659 addNamedSource('/a.dart', 'part of my.lib; int get x => 42;'); |
| 1641 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}'); | 1660 addNamedSource('/b.dart', 'part of my.lib; void set x(int _) {}'); |
| 1642 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 1661 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 1643 } | 1662 } |
| 1644 | 1663 |
| 1645 test_variable_implicit_type() { | 1664 test_variable_implicit_type() { |
| 1646 checkLibrary('var x;'); | 1665 checkLibrary('var x;'); |
| 1647 } | 1666 } |
| 1648 | 1667 |
| 1668 test_variable_inferred_type_implicit_initialized() { |
| 1669 checkLibrary('var v = 0;'); |
| 1670 } |
| 1671 |
| 1649 test_variable_propagatedType_const_noDep() { | 1672 test_variable_propagatedType_const_noDep() { |
| 1650 if (analysisContext.analysisOptions.strongMode) { | |
| 1651 // TODO(paulberry): fix this test in strong mode. | |
| 1652 return; | |
| 1653 } | |
| 1654 checkLibrary('const i = 0;'); | 1673 checkLibrary('const i = 0;'); |
| 1655 } | 1674 } |
| 1656 | 1675 |
| 1657 test_variable_propagatedType_final_dep_inLib() { | 1676 test_variable_propagatedType_final_dep_inLib() { |
| 1658 if (analysisContext.analysisOptions.strongMode) { | |
| 1659 // TODO(paulberry): fix this test in strong mode. | |
| 1660 return; | |
| 1661 } | |
| 1662 addNamedSource('/a.dart', 'final a = 1;'); | 1677 addNamedSource('/a.dart', 'final a = 1;'); |
| 1663 checkLibrary('import "a.dart"; final b = a / 2;'); | 1678 checkLibrary('import "a.dart"; final b = a / 2;'); |
| 1664 } | 1679 } |
| 1665 | 1680 |
| 1666 test_variable_propagatedType_final_dep_inPart() { | 1681 test_variable_propagatedType_final_dep_inPart() { |
| 1667 if (analysisContext.analysisOptions.strongMode) { | |
| 1668 // TODO(paulberry): fix this test in strong mode. | |
| 1669 return; | |
| 1670 } | |
| 1671 addNamedSource('/a.dart', 'part of lib; final a = 1;'); | 1682 addNamedSource('/a.dart', 'part of lib; final a = 1;'); |
| 1672 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); | 1683 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); |
| 1673 } | 1684 } |
| 1674 | 1685 |
| 1675 test_variable_propagatedType_final_noDep() { | 1686 test_variable_propagatedType_final_noDep() { |
| 1676 if (analysisContext.analysisOptions.strongMode) { | |
| 1677 // TODO(paulberry): fix this test in strong mode. | |
| 1678 return; | |
| 1679 } | |
| 1680 checkLibrary('final i = 0;'); | 1687 checkLibrary('final i = 0;'); |
| 1681 } | 1688 } |
| 1682 | 1689 |
| 1683 test_variable_propagatedType_implicit_dep() { | 1690 test_variable_propagatedType_implicit_dep() { |
| 1684 if (analysisContext.analysisOptions.strongMode) { | |
| 1685 // TODO(paulberry): fix this test in strong mode. | |
| 1686 return; | |
| 1687 } | |
| 1688 // The propagated type is defined in a library that is not imported. | 1691 // The propagated type is defined in a library that is not imported. |
| 1689 addNamedSource('/a.dart', 'class C {}'); | 1692 addNamedSource('/a.dart', 'class C {}'); |
| 1690 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;'); | 1693 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;'); |
| 1691 checkLibrary('import "b.dart"; final x = f();'); | 1694 checkLibrary('import "b.dart"; final x = f();'); |
| 1692 } | 1695 } |
| 1693 | 1696 |
| 1694 test_variable_setterInPart_getterInPart() { | 1697 test_variable_setterInPart_getterInPart() { |
| 1695 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); | 1698 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); |
| 1696 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); | 1699 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); |
| 1697 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 1700 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 1698 } | 1701 } |
| 1699 | 1702 |
| 1700 test_variables() { | 1703 test_variables() { |
| 1701 checkLibrary('int i; int j;'); | 1704 checkLibrary('int i; int j;'); |
| 1702 } | 1705 } |
| 1703 } | 1706 } |
| 1704 | 1707 |
| 1705 class _TestSummaryResynthesizer extends SummaryResynthesizer { | 1708 class _TestSummaryResynthesizer extends SummaryResynthesizer { |
| 1706 final Map<String, UnlinkedUnit> unlinkedSummaries; | 1709 final Map<String, UnlinkedUnit> unlinkedSummaries; |
| 1707 final Map<String, LinkedLibrary> linkedSummaries; | 1710 final Map<String, LinkedLibrary> linkedSummaries; |
| 1708 | 1711 |
| 1709 _TestSummaryResynthesizer( | 1712 _TestSummaryResynthesizer( |
| 1710 SummaryResynthesizer parent, | 1713 SummaryResynthesizer parent, |
| 1711 AnalysisContext context, | 1714 AnalysisContext context, |
| 1712 TypeProvider typeProvider, | 1715 TypeProvider typeProvider, |
| 1713 SourceFactory sourceFactory, | 1716 SourceFactory sourceFactory, |
| 1714 this.unlinkedSummaries, | 1717 this.unlinkedSummaries, |
| 1715 this.linkedSummaries) | 1718 this.linkedSummaries, |
| 1716 : super(parent, context, typeProvider, sourceFactory); | 1719 bool strongMode) |
| 1720 : super(parent, context, typeProvider, sourceFactory, strongMode); |
| 1717 | 1721 |
| 1718 @override | 1722 @override |
| 1719 LinkedLibrary getLinkedSummary(String uri) { | 1723 LinkedLibrary getLinkedSummary(String uri) { |
| 1720 LinkedLibrary serializedLibrary = linkedSummaries[uri]; | 1724 LinkedLibrary serializedLibrary = linkedSummaries[uri]; |
| 1721 if (serializedLibrary == null) { | 1725 if (serializedLibrary == null) { |
| 1722 fail('Unexpectedly tried to get linked summary for $uri'); | 1726 fail('Unexpectedly tried to get linked summary for $uri'); |
| 1723 } | 1727 } |
| 1724 return serializedLibrary; | 1728 return serializedLibrary; |
| 1725 } | 1729 } |
| 1726 | 1730 |
| 1727 @override | 1731 @override |
| 1728 UnlinkedUnit getUnlinkedSummary(String uri) { | 1732 UnlinkedUnit getUnlinkedSummary(String uri) { |
| 1729 UnlinkedUnit serializedUnit = unlinkedSummaries[uri]; | 1733 UnlinkedUnit serializedUnit = unlinkedSummaries[uri]; |
| 1730 if (serializedUnit == null) { | 1734 if (serializedUnit == null) { |
| 1731 fail('Unexpectedly tried to get unlinked summary for $uri'); | 1735 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 1732 } | 1736 } |
| 1733 return serializedUnit; | 1737 return serializedUnit; |
| 1734 } | 1738 } |
| 1735 | 1739 |
| 1736 @override | 1740 @override |
| 1737 bool hasLibrarySummary(String uri) { | 1741 bool hasLibrarySummary(String uri) { |
| 1738 return true; | 1742 return true; |
| 1739 } | 1743 } |
| 1740 } | 1744 } |
| OLD | NEW |