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

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

Issue 2092873002: fix #25794, infer parameter type from default value (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge remote-tracking branch 'origin/master' into 25794_param_infer Created 4 years, 5 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:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/constant/value.dart'; 10 import 'package:analyzer/dart/constant/value.dart';
(...skipping 4089 matching lines...) Expand 10 before | Expand all | Expand 10 after
4100 } 4100 }
4101 4101
4102 test_operator_index_set() { 4102 test_operator_index_set() {
4103 checkLibrary('class C { void operator[]=(int i, bool v) {} }'); 4103 checkLibrary('class C { void operator[]=(int i, bool v) {} }');
4104 } 4104 }
4105 4105
4106 test_operator_less_equal() { 4106 test_operator_less_equal() {
4107 checkLibrary('class C { bool operator<=(C other) => false; }'); 4107 checkLibrary('class C { bool operator<=(C other) => false; }');
4108 } 4108 }
4109 4109
4110 test_parameterTypeNotInferred_constructor() { 4110 test_parameterType_inferred_constructor() {
4111 // Strong mode doesn't do type inference on constructor parameters, so it's
4112 // ok that we don't store inferred type info for them in summaries.
4113 checkLibrary(''' 4111 checkLibrary('''
4114 class C { 4112 class C {
4115 C.positional([x = 1]); 4113 C.positional([x = 1]);
4116 C.named({x: 1}); 4114 C.named({x: 1});
4117 } 4115 }
4118 '''); 4116 ''');
4119 } 4117 }
4120 4118
4121 test_parameterTypeNotInferred_initializingFormal() { 4119 test_parameterType_inferred_staticMethod() {
4122 // Strong mode doesn't do type inference on initializing formals, so it's
4123 // ok that we don't store inferred type info for them in summaries.
4124 checkLibrary('''
4125 class C {
4126 var x;
4127 C.positional([this.x = 1]);
4128 C.named({this.x: 1});
4129 }
4130 ''');
4131 }
4132
4133 test_parameterTypeNotInferred_staticMethod() {
4134 // Strong mode doesn't do type inference on parameters of static methods,
4135 // so it's ok that we don't store inferred type info for them in summaries.
4136 checkLibrary(''' 4120 checkLibrary('''
4137 class C { 4121 class C {
4138 static void positional([x = 1]) {} 4122 static void positional([x = 1]) {}
4139 static void named({x: 1}) {} 4123 static void named({x: 1}) {}
4140 } 4124 }
4141 '''); 4125 ''');
4142 } 4126 }
4143 4127
4144 test_parameterTypeNotInferred_topLevelFunction() { 4128 test_parameterType_inferred_topLevelFunction() {
4145 // Strong mode doesn't do type inference on parameters of top level
4146 // functions, so it's ok that we don't store inferred type info for them in
4147 // summaries.
4148 checkLibrary(''' 4129 checkLibrary('''
4149 void positional([x = 1]) {} 4130 void positional([x = 1]) {}
4150 void named({x: 1}) {} 4131 void named({x: 1}) {}
4151 '''); 4132 ''');
4152 } 4133 }
4153 4134
4135 test_parameterTypeNotInferred_initializingFormal() {
4136 // Strong mode doesn't do type inference on initializing formals, so it's
4137 // ok that we don't store inferred type info for them in summaries.
4138 checkLibrary('''
4139 class C {
4140 var x;
4141 C.positional([this.x = 1]);
4142 C.named({this.x: 1});
4143 }
4144 ''');
4145 }
4146
4154 test_parts() { 4147 test_parts() {
4155 addSource('/a.dart', 'part of my.lib;'); 4148 addSource('/a.dart', 'part of my.lib;');
4156 addSource('/b.dart', 'part of my.lib;'); 4149 addSource('/b.dart', 'part of my.lib;');
4157 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); 4150 checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
4158 } 4151 }
4159 4152
4160 test_propagated_type_refers_to_closure() { 4153 test_propagated_type_refers_to_closure() {
4161 checkLibrary(''' 4154 checkLibrary('''
4162 void f() { 4155 void f() {
4163 var x = () => 0; 4156 var x = () => 0;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4619 fail('Unexpectedly tried to get unlinked summary for $uri'); 4612 fail('Unexpectedly tried to get unlinked summary for $uri');
4620 } 4613 }
4621 return serializedUnit; 4614 return serializedUnit;
4622 } 4615 }
4623 4616
4624 @override 4617 @override
4625 bool hasLibrarySummary(String uri) { 4618 bool hasLibrarySummary(String uri) {
4626 return true; 4619 return true;
4627 } 4620 }
4628 } 4621 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_ast_test.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698