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

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

Issue 3008453002: Build / resynthesize final fields as ConstFieldElementImpl only if the enclosing class has a consta… (Closed)
Patch Set: Created 3 years, 4 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
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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 3775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3786 var library = await checkLibrary(r''' 3786 var library = await checkLibrary(r'''
3787 typedef F(); 3787 typedef F();
3788 class C { 3788 class C {
3789 final f = <F>[]; 3789 final f = <F>[];
3790 } 3790 }
3791 '''); 3791 ''');
3792 if (isStrongMode) { 3792 if (isStrongMode) {
3793 checkElementText(library, r''' 3793 checkElementText(library, r'''
3794 typedef dynamic F(); 3794 typedef dynamic F();
3795 class C { 3795 class C {
3796 final List<F> f = const < 3796 final List<F> f;
3797 F/*location: test.dart;F*/>[];
3798 } 3797 }
3799 '''); 3798 ''');
3800 } else { 3799 } else {
3801 checkElementText(library, r''' 3800 checkElementText(library, r'''
3802 typedef dynamic F(); 3801 typedef dynamic F();
3803 class C { 3802 class C {
3804 final dynamic f = const < 3803 final dynamic f;
3805 F/*location: test.dart;F*/>[];
3806 } 3804 }
3807 '''); 3805 ''');
3808 } 3806 }
3809 } 3807 }
3810 3808
3811 test_const_reference_type_imported() async { 3809 test_const_reference_type_imported() async {
3812 addLibrarySource('/a.dart', r''' 3810 addLibrarySource('/a.dart', r'''
3813 class C {} 3811 class C {}
3814 enum E {a, b, c} 3812 enum E {a, b, c}
3815 typedef F(int a, String b); 3813 typedef F(int a, String b);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3886 3884
3887 test_const_reference_type_typeParameter() async { 3885 test_const_reference_type_typeParameter() async {
3888 var library = await checkLibrary(r''' 3886 var library = await checkLibrary(r'''
3889 class C<T> { 3887 class C<T> {
3890 final f = <T>[]; 3888 final f = <T>[];
3891 } 3889 }
3892 '''); 3890 ''');
3893 if (isStrongMode) { 3891 if (isStrongMode) {
3894 checkElementText(library, r''' 3892 checkElementText(library, r'''
3895 class C<T> { 3893 class C<T> {
3896 final List<T> f = const < 3894 final List<T> f;
3897 T/*location: test.dart;C;T*/>[];
3898 } 3895 }
3899 '''); 3896 ''');
3900 } else { 3897 } else {
3901 checkElementText(library, r''' 3898 checkElementText(library, r'''
3902 class C<T> { 3899 class C<T> {
3903 final dynamic f = const < 3900 final dynamic f;
3904 T/*location: test.dart;C;T*/>[];
3905 } 3901 }
3906 '''); 3902 ''');
3907 } 3903 }
3908 } 3904 }
3909 3905
3910 test_const_reference_unresolved_prefix0() async { 3906 test_const_reference_unresolved_prefix0() async {
3911 var library = await checkLibrary(r''' 3907 var library = await checkLibrary(r'''
3912 const V = foo; 3908 const V = foo;
3913 ''', allowErrors: true); 3909 ''', allowErrors: true);
3914 checkElementText(library, r''' 3910 checkElementText(library, r'''
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5714 addLibrarySource('/a.dart', 'final a = 1;'); 5710 addLibrarySource('/a.dart', 'final a = 1;');
5715 var library = await checkLibrary(''' 5711 var library = await checkLibrary('''
5716 import "a.dart"; 5712 import "a.dart";
5717 class C { 5713 class C {
5718 final b = a / 2; 5714 final b = a / 2;
5719 }'''); 5715 }''');
5720 if (isStrongMode) { 5716 if (isStrongMode) {
5721 checkElementText(library, r''' 5717 checkElementText(library, r'''
5722 import 'a.dart'; 5718 import 'a.dart';
5723 class C { 5719 class C {
5724 final double b = 5720 final double b;
5725 a/*location: a.dart;a?*/ / 2;
5726 } 5721 }
5727 '''); 5722 ''');
5728 } else { 5723 } else {
5729 checkElementText(library, r''' 5724 checkElementText(library, r'''
5730 import 'a.dart'; 5725 import 'a.dart';
5731 class C { 5726 class C {
5732 final dynamic b = 5727 final dynamic b;
5733 a/*location: a.dart;a?*/ / 2;
5734 } 5728 }
5735 '''); 5729 ''');
5736 } 5730 }
5737 } 5731 }
5738 5732
5739 test_field_propagatedType_final_dep_inPart() async { 5733 test_field_propagatedType_final_dep_inPart() async {
5740 addSource('/a.dart', 'part of lib; final a = 1;'); 5734 addSource('/a.dart', 'part of lib; final a = 1;');
5741 var library = await checkLibrary(''' 5735 var library = await checkLibrary('''
5742 library lib; 5736 library lib;
5743 part "a.dart"; 5737 part "a.dart";
5744 class C { 5738 class C {
5745 final b = a / 2; 5739 final b = a / 2;
5746 }'''); 5740 }''');
5747 if (isStrongMode) { 5741 if (isStrongMode) {
5748 checkElementText(library, r''' 5742 checkElementText(library, r'''
5749 library lib; 5743 library lib;
5750 part 'a.dart'; 5744 part 'a.dart';
5751 class C { 5745 class C {
5752 final double b = 5746 final double b;
5753 a/*location: test.dart;a.dart;a?*/ / 2;
5754 } 5747 }
5755 -------------------- 5748 --------------------
5756 unit: a.dart 5749 unit: a.dart
5757 5750
5758 final int a; 5751 final int a;
5759 '''); 5752 ''');
5760 } else { 5753 } else {
5761 checkElementText(library, r''' 5754 checkElementText(library, r'''
5762 library lib; 5755 library lib;
5763 part 'a.dart'; 5756 part 'a.dart';
5764 class C { 5757 class C {
5765 final dynamic b = 5758 final dynamic b;
5766 a/*location: test.dart;a.dart;a?*/ / 2;
5767 } 5759 }
5768 -------------------- 5760 --------------------
5769 unit: a.dart 5761 unit: a.dart
5770 5762
5771 final dynamic a; 5763 final dynamic a;
5772 '''); 5764 ''');
5773 } 5765 }
5774 } 5766 }
5775 5767
5776 test_field_propagatedType_final_noDep_instance() async { 5768 test_field_propagatedType_final_noDep_instance() async {
5777 var library = await checkLibrary(''' 5769 var library = await checkLibrary('''
5778 class C { 5770 class C {
5779 final x = 0; 5771 final x = 0;
5780 }'''); 5772 }''');
5781 if (isStrongMode) { 5773 if (isStrongMode) {
5782 checkElementText(library, r''' 5774 checkElementText(library, r'''
5783 class C { 5775 class C {
5784 final int x = 0; 5776 final int x;
5785 } 5777 }
5786 '''); 5778 ''');
5787 } else { 5779 } else {
5788 checkElementText(library, r''' 5780 checkElementText(library, r'''
5789 class C { 5781 class C {
5790 final dynamic x = 0; 5782 final dynamic x;
5791 } 5783 }
5792 '''); 5784 ''');
5793 } 5785 }
5794 } 5786 }
5795 5787
5796 test_field_propagatedType_final_noDep_static() async { 5788 test_field_propagatedType_final_noDep_static() async {
5797 var library = await checkLibrary(''' 5789 var library = await checkLibrary('''
5798 class C { 5790 class C {
5799 static final x = 0; 5791 static final x = 0;
5800 }'''); 5792 }''');
(...skipping 4287 matching lines...) Expand 10 before | Expand all | Expand 10 after
10088 fail('Unexpectedly tried to get unlinked summary for $uri'); 10080 fail('Unexpectedly tried to get unlinked summary for $uri');
10089 } 10081 }
10090 return serializedUnit; 10082 return serializedUnit;
10091 } 10083 }
10092 10084
10093 @override 10085 @override
10094 bool hasLibrarySummary(String uri) { 10086 bool hasLibrarySummary(String uri) {
10095 return true; 10087 return true;
10096 } 10088 }
10097 } 10089 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698