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

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

Issue 1624853002: Store the result of type inference in summaries. (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
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 analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 26 matching lines...) Expand all
37 AnalysisContext analysisContext = AnalysisContextFactory.contextWithCore(); 37 AnalysisContext analysisContext = AnalysisContextFactory.contextWithCore();
38 Map<String, UnlinkedPublicNamespace> uriToNamespace = 38 Map<String, UnlinkedPublicNamespace> uriToNamespace =
39 <String, UnlinkedPublicNamespace>{}; 39 <String, UnlinkedPublicNamespace>{};
40 List<LibraryElement> libraries = [ 40 List<LibraryElement> libraries = [
41 analysisContext.typeProvider.objectType.element.library, 41 analysisContext.typeProvider.objectType.element.library,
42 analysisContext.typeProvider.futureType.element.library 42 analysisContext.typeProvider.futureType.element.library
43 ]; 43 ];
44 for (LibraryElement library in libraries) { 44 for (LibraryElement library in libraries) {
45 summarize_elements.LibrarySerializationResult serializedLibrary = 45 summarize_elements.LibrarySerializationResult serializedLibrary =
46 summarize_elements.serializeLibrary( 46 summarize_elements.serializeLibrary(
47 library, analysisContext.typeProvider); 47 library, analysisContext.typeProvider, false);
48 for (int i = 0; i < serializedLibrary.unlinkedUnits.length; i++) { 48 for (int i = 0; i < serializedLibrary.unlinkedUnits.length; i++) {
49 uriToNamespace[serializedLibrary.unitUris[i]] = 49 uriToNamespace[serializedLibrary.unitUris[i]] =
50 new UnlinkedUnit.fromBuffer( 50 new UnlinkedUnit.fromBuffer(
51 serializedLibrary.unlinkedUnits[i].toBuffer()).publicNamespace; 51 serializedLibrary.unlinkedUnits[i].toBuffer()).publicNamespace;
52 } 52 }
53 } 53 }
54 return uriToNamespace; 54 return uriToNamespace;
55 } catch (_) { 55 } catch (_) {
56 return null; 56 return null;
57 } 57 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 */ 152 */
153 LinkedLibrary get linked; 153 LinkedLibrary get linked;
154 154
155 /** 155 /**
156 * `true` if the linked portion of the summary only contains prelinked data. 156 * `true` if the linked portion of the summary only contains prelinked data.
157 * This happens because we don't yet have a full linker; only a prelinker. 157 * This happens because we don't yet have a full linker; only a prelinker.
158 */ 158 */
159 bool get skipFullyLinkedData; 159 bool get skipFullyLinkedData;
160 160
161 /** 161 /**
162 * `true` if the linked portion of the summary contains the result of strong
163 * mode analysis.
164 */
165 bool get strongMode;
166
167 /**
162 * Get access to the unlinked compilation unit summaries that result from 168 * Get access to the unlinked compilation unit summaries that result from
163 * serializing and deserializing the library under test. 169 * serializing and deserializing the library under test.
164 */ 170 */
165 List<UnlinkedUnit> get unlinkedUnits; 171 List<UnlinkedUnit> get unlinkedUnits;
166 172
167 /** 173 /**
168 * Convert [path] to a suitably formatted absolute path URI for the current 174 * Convert [path] to a suitably formatted absolute path URI for the current
169 * platform. 175 * platform.
170 */ 176 */
171 String absUri(String path) { 177 String absUri(String path) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 291 }
286 return i; 292 return i;
287 } 293 }
288 found.add(dep.uri); 294 found.add(dep.uri);
289 } 295 }
290 fail('Did not find dependency $relativeUri. Found: $found'); 296 fail('Did not find dependency $relativeUri. Found: $found');
291 return null; 297 return null;
292 } 298 }
293 299
294 /** 300 /**
301 * Test an inferred type. If strong mode is disabled, verify that the given
302 * [slotId] exists and has no associated type. Otherwise, behave as in
303 * [checkLinkedTypeSlot].
304 */
305 void checkInferredTypeSlot(
306 int slotId, String absoluteUri, String relativeUri, String expectedName,
307 {bool allowTypeParameters: false,
308 ReferenceKind expectedKind: ReferenceKind.classOrEnum,
309 int expectedTargetUnit: 0,
310 LinkedUnit linkedSourceUnit,
311 UnlinkedUnit unlinkedSourceUnit,
312 int numTypeParameters: 0}) {
313 if (strongMode) {
314 checkLinkedTypeSlot(slotId, absoluteUri, relativeUri, expectedName,
315 allowTypeParameters: allowTypeParameters,
316 expectedKind: expectedKind,
317 expectedTargetUnit: expectedTargetUnit,
318 linkedSourceUnit: linkedSourceUnit,
319 unlinkedSourceUnit: unlinkedSourceUnit,
320 numTypeParameters: numTypeParameters);
321 } else {
322 // A slot id should have been assigned but it should not be associated
323 // with any type.
324 expect(slotId, isNot(0));
325 expect(getTypeRefForSlot(slotId, linkedSourceUnit: linkedSourceUnit),
326 isNull);
327 }
328 }
329
330 /**
295 * Verify that the dependency table *does not* contain any entries for a file 331 * Verify that the dependency table *does not* contain any entries for a file
296 * reachable via the given [absoluteUri] and [relativeUri]. 332 * reachable via the given [absoluteUri] and [relativeUri].
297 */ 333 */
298 void checkLacksDependency(String absoluteUri, String relativeUri) { 334 void checkLacksDependency(String absoluteUri, String relativeUri) {
299 if (expectAbsoluteUrisInDependencies) { 335 if (expectAbsoluteUrisInDependencies) {
300 // The element model doesn't (yet) store enough information to recover 336 // The element model doesn't (yet) store enough information to recover
301 // relative URIs, so we have to use the absolute URI. 337 // relative URIs, so we have to use the absolute URI.
302 // TODO(paulberry): fix this. 338 // TODO(paulberry): fix this.
303 relativeUri = absoluteUri; 339 relativeUri = absoluteUri;
304 } 340 }
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 executables: serializeClassText('class C { C(); }').executables); 2213 executables: serializeClassText('class C { C(); }').executables);
2178 expect(executable.isConst, isFalse); 2214 expect(executable.isConst, isFalse);
2179 } 2215 }
2180 2216
2181 test_constructor_non_factory() { 2217 test_constructor_non_factory() {
2182 UnlinkedExecutable executable = findExecutable('', 2218 UnlinkedExecutable executable = findExecutable('',
2183 executables: serializeClassText('class C { C(); }').executables); 2219 executables: serializeClassText('class C { C(); }').executables);
2184 expect(executable.isFactory, isFalse); 2220 expect(executable.isFactory, isFalse);
2185 } 2221 }
2186 2222
2223 test_constructor_param_inferred_type_explicit() {
2224 UnlinkedExecutable ctor =
2225 serializeClassText('class C { C(int v); }').executables[0];
2226 expect(ctor.kind, UnlinkedExecutableKind.constructor);
2227 expect(ctor.parameters[0].inferredTypeSlot, 0);
2228 }
2229
2230 test_constructor_param_inferred_type_implicit() {
2231 UnlinkedExecutable ctor =
2232 serializeClassText('class C { C(v); }').executables[0];
2233 expect(ctor.kind, UnlinkedExecutableKind.constructor);
2234 expect(ctor.parameters[0].inferredTypeSlot, 0);
2235 }
2236
2187 test_constructor_return_type() { 2237 test_constructor_return_type() {
2188 UnlinkedExecutable executable = findExecutable('', 2238 UnlinkedExecutable executable = findExecutable('',
2189 executables: serializeClassText('class C { C(); }').executables); 2239 executables: serializeClassText('class C { C(); }').executables);
2190 expect(executable.returnType, isNull); 2240 expect(executable.returnType, isNull);
2191 } 2241 }
2192 2242
2193 test_constructor_return_type_parameterized() { 2243 test_constructor_return_type_parameterized() {
2194 UnlinkedExecutable executable = findExecutable('', 2244 UnlinkedExecutable executable = findExecutable('',
2195 executables: serializeClassText('class C<T, U> { C(); }').executables); 2245 executables: serializeClassText('class C<T, U> { C(); }').executables);
2196 expect(executable.returnType, isNull); 2246 expect(executable.returnType, isNull);
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 expect(variable.documentationComment, isNotNull); 3160 expect(variable.documentationComment, isNotNull);
3111 checkDocumentationComment(variable.documentationComment, text); 3161 checkDocumentationComment(variable.documentationComment, text);
3112 } 3162 }
3113 3163
3114 test_field_final() { 3164 test_field_final() {
3115 UnlinkedVariable variable = 3165 UnlinkedVariable variable =
3116 serializeClassText('class C { final int i = 0; }').fields[0]; 3166 serializeClassText('class C { final int i = 0; }').fields[0];
3117 expect(variable.isFinal, isTrue); 3167 expect(variable.isFinal, isTrue);
3118 } 3168 }
3119 3169
3170 test_field_formal_param_inferred_type_explicit() {
3171 UnlinkedClass cls = serializeClassText(
3172 'class C extends D { var v; C(int this.v); }'
3173 ' abstract class D { num get v; }',
3174 className: 'C');
3175 checkInferredTypeSlot(
3176 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'num');
3177 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor);
3178 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0);
3179 }
3180
3181 test_field_formal_param_inferred_type_implicit() {
3182 // Both the field `v` and the constructor argument `this.v` will have their
3183 // type inferred by strong mode. But only the field should have its
3184 // inferred type stored in the summary, since the standard rules for field
3185 // formal parameters will take care of the rest (they implicitly inherit
3186 // the type of the associated field).
3187 UnlinkedClass cls = serializeClassText(
3188 'class C extends D { var v; C(this.v); }'
3189 ' abstract class D { int get v; }',
3190 className: 'C');
3191 checkInferredTypeSlot(
3192 cls.fields[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3193 expect(cls.executables[0].kind, UnlinkedExecutableKind.constructor);
3194 expect(cls.executables[0].parameters[0].inferredTypeSlot, 0);
3195 }
3196
3197 test_field_inferred_type_nonstatic_explicit_initialized() {
3198 UnlinkedVariable v = serializeClassText('class C { num v = 0; }').fields[0];
3199 expect(v.inferredTypeSlot, 0);
3200 }
3201
3202 test_field_inferred_type_nonstatic_explicit_uninitialized() {
3203 UnlinkedVariable v = serializeClassText(
3204 'class C extends D { num v; } abstract class D { int get v; }',
3205 className: 'C',
3206 allowErrors: true).fields[0];
3207 expect(v.inferredTypeSlot, 0);
3208 }
3209
3210 test_field_inferred_type_nonstatic_implicit_initialized() {
3211 UnlinkedVariable v = serializeClassText('class C { var v = 0; }').fields[0];
3212 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3213 }
3214
3215 test_field_inferred_type_nonstatic_implicit_uninitialized() {
3216 UnlinkedVariable v = serializeClassText(
3217 'class C extends D { var v; } abstract class D { int get v; }',
3218 className: 'C').fields[0];
3219 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3220 }
3221
3222 test_field_inferred_type_static_explicit_initialized() {
3223 UnlinkedVariable v =
3224 serializeClassText('class C { static int v = 0; }').fields[0];
3225 expect(v.inferredTypeSlot, 0);
3226 }
3227
3228 test_field_inferred_type_static_implicit_initialized() {
3229 UnlinkedVariable v =
3230 serializeClassText('class C { static var v = 0; }').fields[0];
3231 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3232 }
3233
3234 test_field_inferred_type_static_implicit_uninitialized() {
3235 UnlinkedVariable v =
3236 serializeClassText('class C { static var v; }').fields[0];
3237 expect(v.inferredTypeSlot, 0);
3238 }
3239
3120 test_field_propagated_type_final_immediate() { 3240 test_field_propagated_type_final_immediate() {
3121 UnlinkedVariable v = 3241 UnlinkedVariable v =
3122 serializeClassText('class C { final v = 0; }').fields[0]; 3242 serializeClassText('class C { final v = 0; }').fields[0];
3123 checkLinkedTypeSlot(v.propagatedTypeSlot, 'dart:core', 'dart:core', 'int'); 3243 checkLinkedTypeSlot(v.propagatedTypeSlot, 'dart:core', 'dart:core', 'int');
3124 } 3244 }
3125 3245
3126 test_field_static() { 3246 test_field_static() {
3127 UnlinkedVariable variable = 3247 UnlinkedVariable variable =
3128 serializeClassText('class C { static int i; }').fields[0]; 3248 serializeClassText('class C { static int i; }').fields[0];
3129 expect(variable.isStatic, isTrue); 3249 expect(variable.isStatic, isTrue);
(...skipping 22 matching lines...) Expand all
3152 // Extra comment so doc comment offset != 0 3272 // Extra comment so doc comment offset != 0
3153 /** 3273 /**
3154 * Docs 3274 * Docs
3155 */ 3275 */
3156 f() {}'''; 3276 f() {}''';
3157 UnlinkedExecutable executable = serializeExecutableText(text); 3277 UnlinkedExecutable executable = serializeExecutableText(text);
3158 expect(executable.documentationComment, isNotNull); 3278 expect(executable.documentationComment, isNotNull);
3159 checkDocumentationComment(executable.documentationComment, text); 3279 checkDocumentationComment(executable.documentationComment, text);
3160 } 3280 }
3161 3281
3282 test_function_inferred_type_implicit_param() {
3283 UnlinkedExecutable f = serializeExecutableText('void f(value) {}');
3284 expect(f.parameters[0].inferredTypeSlot, 0);
3285 }
3286
3287 test_function_inferred_type_implicit_return() {
3288 UnlinkedExecutable f = serializeExecutableText('f() => null;');
3289 expect(f.inferredReturnTypeSlot, 0);
3290 }
3291
3162 test_generic_method_in_generic_class() { 3292 test_generic_method_in_generic_class() {
3163 UnlinkedClass cls = serializeClassText( 3293 UnlinkedClass cls = serializeClassText(
3164 'class C<T, U> { void m<V, W>(T t, U u, V v, W w) {} }'); 3294 'class C<T, U> { void m<V, W>(T t, U u, V v, W w) {} }');
3165 List<UnlinkedParam> params = cls.executables[0].parameters; 3295 List<UnlinkedParam> params = cls.executables[0].parameters;
3166 checkParamTypeRef(params[0].type, 4); 3296 checkParamTypeRef(params[0].type, 4);
3167 checkParamTypeRef(params[1].type, 3); 3297 checkParamTypeRef(params[1].type, 3);
3168 checkParamTypeRef(params[2].type, 2); 3298 checkParamTypeRef(params[2].type, 2);
3169 checkParamTypeRef(params[3].type, 1); 3299 checkParamTypeRef(params[3].type, 1);
3170 } 3300 }
3171 3301
3172 test_getter_documented() { 3302 test_getter_documented() {
3173 String text = ''' 3303 String text = '''
3174 // Extra comment so doc comment offset != 0 3304 // Extra comment so doc comment offset != 0
3175 /** 3305 /**
3176 * Docs 3306 * Docs
3177 */ 3307 */
3178 get f => null;'''; 3308 get f => null;''';
3179 UnlinkedExecutable executable = serializeExecutableText(text); 3309 UnlinkedExecutable executable = serializeExecutableText(text);
3180 expect(executable.documentationComment, isNotNull); 3310 expect(executable.documentationComment, isNotNull);
3181 checkDocumentationComment(executable.documentationComment, text); 3311 checkDocumentationComment(executable.documentationComment, text);
3182 } 3312 }
3183 3313
3314 test_getter_inferred_type_nonstatic_explicit_return() {
3315 UnlinkedExecutable f = serializeClassText(
3316 'class C extends D { num get f => null; }'
3317 ' abstract class D { int get f; }',
3318 className: 'C',
3319 allowErrors: true).executables[0];
3320 expect(f.inferredReturnTypeSlot, 0);
3321 }
3322
3323 test_getter_inferred_type_nonstatic_implicit_return() {
3324 UnlinkedExecutable f = serializeClassText(
3325 'class C extends D { get f => null; } abstract class D { int get f; }',
3326 className: 'C').executables[0];
3327 checkInferredTypeSlot(
3328 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int');
3329 }
3330
3331 test_getter_inferred_type_static_implicit_return() {
3332 UnlinkedExecutable f = serializeClassText(
3333 'class C extends D { static get f => null; }'
3334 ' class D { static int get f => null; }',
3335 className: 'C').executables[0];
3336 expect(f.inferredReturnTypeSlot, 0);
3337 }
3338
3184 test_implicit_dependencies_follow_other_dependencies() { 3339 test_implicit_dependencies_follow_other_dependencies() {
3185 if (skipFullyLinkedData) { 3340 if (skipFullyLinkedData) {
3186 return; 3341 return;
3187 } 3342 }
3188 addNamedSource('/a.dart', 'import "b.dart"; class C {} D f() => null;'); 3343 addNamedSource('/a.dart', 'import "b.dart"; class C {} D f() => null;');
3189 addNamedSource('/b.dart', 'class D {}'); 3344 addNamedSource('/b.dart', 'class D {}');
3190 serializeLibraryText('import "a.dart"; final x = f(); C y;'); 3345 serializeLibraryText('import "a.dart"; final x = f(); C y;');
3191 // The dependency on b.dart is implicit, so it should be placed at the end 3346 // The dependency on b.dart is implicit, so it should be placed at the end
3192 // of the dependency list, after a.dart, even though the code that refers 3347 // of the dependency list, after a.dart, even though the code that refers
3193 // to b.dart comes before the code that refers to a.dart. 3348 // to b.dart comes before the code that refers to a.dart.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 /** 3712 /**
3558 * Docs 3713 * Docs
3559 */ 3714 */
3560 f() {} 3715 f() {}
3561 }'''; 3716 }''';
3562 UnlinkedExecutable executable = serializeClassText(text).executables[0]; 3717 UnlinkedExecutable executable = serializeClassText(text).executables[0];
3563 expect(executable.documentationComment, isNotNull); 3718 expect(executable.documentationComment, isNotNull);
3564 checkDocumentationComment(executable.documentationComment, text); 3719 checkDocumentationComment(executable.documentationComment, text);
3565 } 3720 }
3566 3721
3722 test_method_inferred_type_nonstatic_explicit_param() {
3723 UnlinkedExecutable f = serializeClassText(
3724 'class C extends D { void f(num value) {} }'
3725 ' abstract class D { void f(int value); }',
3726 className: 'C').executables[0];
3727 expect(f.parameters[0].inferredTypeSlot, 0);
3728 }
3729
3730 test_method_inferred_type_nonstatic_explicit_return() {
3731 UnlinkedExecutable f = serializeClassText(
3732 'class C extends D { num f() => null; } abstract class D { int f(); }',
3733 className: 'C',
3734 allowErrors: true).executables[0];
3735 expect(f.inferredReturnTypeSlot, 0);
3736 }
3737
3738 test_method_inferred_type_nonstatic_implicit_param() {
3739 UnlinkedExecutable f = serializeClassText(
3740 'class C extends D { void f(value) {} }'
3741 ' abstract class D { void f(int value); }',
3742 className: 'C').executables[0];
3743 checkInferredTypeSlot(
3744 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3745 }
3746
3747 test_method_inferred_type_nonstatic_implicit_return() {
3748 UnlinkedExecutable f = serializeClassText(
3749 'class C extends D { f() => null; } abstract class D { int f(); }',
3750 className: 'C').executables[0];
3751 checkInferredTypeSlot(
3752 f.inferredReturnTypeSlot, 'dart:core', 'dart:core', 'int');
3753 }
3754
3755 test_method_inferred_type_static_implicit_param() {
3756 UnlinkedExecutable f = serializeClassText(
3757 'class C extends D { static void f(value) {} }'
3758 ' class D { static void f(int value) {} }',
3759 className: 'C').executables[0];
3760 expect(f.parameters[0].inferredTypeSlot, 0);
3761 }
3762
3763 test_method_inferred_type_static_implicit_return() {
3764 UnlinkedExecutable f = serializeClassText(
3765 'class C extends D { static f() => null; }'
3766 ' class D { static int f() => null; }',
3767 className: 'C').executables[0];
3768 expect(f.inferredReturnTypeSlot, 0);
3769 }
3770
3567 test_part_declaration() { 3771 test_part_declaration() {
3568 addNamedSource('/a.dart', 'part of my.lib;'); 3772 addNamedSource('/a.dart', 'part of my.lib;');
3569 String text = 'library my.lib; part "a.dart"; // <-part'; 3773 String text = 'library my.lib; part "a.dart"; // <-part';
3570 serializeLibraryText(text); 3774 serializeLibraryText(text);
3571 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1)); 3775 expect(unlinkedUnits[0].publicNamespace.parts, hasLength(1));
3572 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart'); 3776 expect(unlinkedUnits[0].publicNamespace.parts[0], 'a.dart');
3573 expect(unlinkedUnits[0].parts, hasLength(1)); 3777 expect(unlinkedUnits[0].parts, hasLength(1));
3574 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"')); 3778 expect(unlinkedUnits[0].parts[0].uriOffset, text.indexOf('"a.dart"'));
3575 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part')); 3779 expect(unlinkedUnits[0].parts[0].uriEnd, text.indexOf('; // <-part'));
3576 } 3780 }
(...skipping 27 matching lines...) Expand all
3604 // Extra comment so doc comment offset != 0 3808 // Extra comment so doc comment offset != 0
3605 /** 3809 /**
3606 * Docs 3810 * Docs
3607 */ 3811 */
3608 void set f(value) {}'''; 3812 void set f(value) {}''';
3609 UnlinkedExecutable executable = serializeExecutableText(text, 'f='); 3813 UnlinkedExecutable executable = serializeExecutableText(text, 'f=');
3610 expect(executable.documentationComment, isNotNull); 3814 expect(executable.documentationComment, isNotNull);
3611 checkDocumentationComment(executable.documentationComment, text); 3815 checkDocumentationComment(executable.documentationComment, text);
3612 } 3816 }
3613 3817
3818 test_setter_inferred_type_nonstatic_explicit_param() {
3819 UnlinkedExecutable f = serializeClassText(
3820 'class C extends D { void set f(num value) {} }'
3821 ' abstract class D { void set f(int value); }',
3822 className: 'C').executables[0];
3823 expect(f.parameters[0].inferredTypeSlot, 0);
3824 }
3825
3826 test_setter_inferred_type_nonstatic_explicit_return() {
3827 UnlinkedExecutable f =
3828 serializeClassText('class C { void set f(int value) {} }').executables[
3829 0];
3830 expect(f.inferredReturnTypeSlot, 0);
3831 }
3832
3833 test_setter_inferred_type_nonstatic_implicit_param() {
3834 UnlinkedExecutable f = serializeClassText(
3835 'class C extends D { void set f(value) {} }'
3836 ' abstract class D { void set f(int value); }',
3837 className: 'C').executables[0];
3838 checkInferredTypeSlot(
3839 f.parameters[0].inferredTypeSlot, 'dart:core', 'dart:core', 'int');
3840 }
3841
3842 test_setter_inferred_type_nonstatic_implicit_return() {
3843 UnlinkedExecutable f =
3844 serializeClassText('class C { set f(int value) {} }').executables[0];
3845 checkInferredTypeSlot(f.inferredReturnTypeSlot, null, null, 'void');
3846 }
3847
3848 test_setter_inferred_type_static_implicit_param() {
3849 UnlinkedExecutable f = serializeClassText(
3850 'class C extends D { static void set f(value) {} }'
3851 ' class D { static void set f(int value) {} }',
3852 className: 'C').executables[0];
3853 expect(f.parameters[0].inferredTypeSlot, 0);
3854 }
3855
3856 test_setter_inferred_type_static_implicit_return() {
3857 UnlinkedExecutable f =
3858 serializeClassText('class C { static set f(int value) {} }')
3859 .executables[0];
3860 expect(f.inferredReturnTypeSlot, 0);
3861 }
3862
3863 test_setter_inferred_type_top_level_implicit_param() {
3864 UnlinkedExecutable f =
3865 serializeExecutableText('void set f(value) {}', 'f=');
3866 expect(f.parameters[0].inferredTypeSlot, 0);
3867 }
3868
3869 test_setter_inferred_type_top_level_implicit_return() {
3870 UnlinkedExecutable f = serializeExecutableText('set f(int value) {}', 'f=');
3871 expect(f.inferredReturnTypeSlot, 0);
3872 }
3873
3614 test_slot_reuse() { 3874 test_slot_reuse() {
3615 // Different compilation units have independent notions of slot id, so slot 3875 // Different compilation units have independent notions of slot id, so slot
3616 // ids should be reused. 3876 // ids should be reused.
3617 addNamedSource('/a.dart', 'part of foo; final v = 0;'); 3877 addNamedSource('/a.dart', 'part of foo; final v = 0;');
3618 serializeLibraryText('library foo; part "a.dart"; final w = 0;'); 3878 serializeLibraryText('library foo; part "a.dart"; final w = 0;');
3619 expect(unlinkedUnits[0].variables[0].propagatedTypeSlot, 1); 3879 expect(unlinkedUnits[0].variables[0].propagatedTypeSlot, 1);
3620 expect(unlinkedUnits[1].variables[0].propagatedTypeSlot, 1); 3880 expect(unlinkedUnits[1].variables[0].propagatedTypeSlot, 1);
3621 } 3881 }
3622 3882
3623 test_type_arguments_explicit() { 3883 test_type_arguments_explicit() {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
4123 UnlinkedVariable variable = 4383 UnlinkedVariable variable =
4124 serializeVariableText('final int i = 0;', variableName: 'i'); 4384 serializeVariableText('final int i = 0;', variableName: 'i');
4125 expect(variable.isFinal, isTrue); 4385 expect(variable.isFinal, isTrue);
4126 } 4386 }
4127 4387
4128 test_variable_implicit_dynamic() { 4388 test_variable_implicit_dynamic() {
4129 UnlinkedVariable variable = serializeVariableText('var v;'); 4389 UnlinkedVariable variable = serializeVariableText('var v;');
4130 expect(variable.type, isNull); 4390 expect(variable.type, isNull);
4131 } 4391 }
4132 4392
4393 test_variable_inferred_type_explicit_initialized() {
4394 UnlinkedVariable v = serializeVariableText('int v = 0;');
4395 expect(v.inferredTypeSlot, 0);
4396 }
4397
4398 test_variable_inferred_type_implicit_initialized() {
4399 UnlinkedVariable v = serializeVariableText('var v = 0;');
4400 checkInferredTypeSlot(v.inferredTypeSlot, 'dart:core', 'dart:core', 'int');
4401 }
4402
4403 test_variable_inferred_type_implicit_uninitialized() {
4404 UnlinkedVariable v = serializeVariableText('var v;');
4405 expect(v.inferredTypeSlot, 0);
4406 }
4407
4133 test_variable_name() { 4408 test_variable_name() {
4134 UnlinkedVariable variable = 4409 UnlinkedVariable variable =
4135 serializeVariableText('int i;', variableName: 'i'); 4410 serializeVariableText('int i;', variableName: 'i');
4136 expect(variable.name, 'i'); 4411 expect(variable.name, 'i');
4137 } 4412 }
4138 4413
4139 test_variable_no_flags() { 4414 test_variable_no_flags() {
4140 UnlinkedVariable variable = 4415 UnlinkedVariable variable =
4141 serializeVariableText('int i;', variableName: 'i'); 4416 serializeVariableText('int i;', variableName: 'i');
4142 expect(variable.isStatic, isFalse); 4417 expect(variable.isStatic, isFalse);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4250 expect(constExpr.operations, operators); 4525 expect(constExpr.operations, operators);
4251 expect(constExpr.ints, ints); 4526 expect(constExpr.ints, ints);
4252 expect(constExpr.doubles, doubles); 4527 expect(constExpr.doubles, doubles);
4253 expect(constExpr.strings, strings); 4528 expect(constExpr.strings, strings);
4254 expect(constExpr.references, hasLength(referenceValidators.length)); 4529 expect(constExpr.references, hasLength(referenceValidators.length));
4255 for (int i = 0; i < referenceValidators.length; i++) { 4530 for (int i = 0; i < referenceValidators.length; i++) {
4256 referenceValidators[i](constExpr.references[i]); 4531 referenceValidators[i](constExpr.references[i]);
4257 } 4532 }
4258 } 4533 }
4259 } 4534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698