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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index ccb9587d19588269d260d14d20633fd42bca4fba..48a6d784ae65f1b63b19c18c229379f14cd343e9 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -723,7 +723,7 @@ class Foo {
}
void f([List<int> l = /*info:INFERRED_TYPE_LITERAL*/const [1]]) {}
// We do this inference in an early task but don't preserve the infos.
-Function2<List<int>, String> g = /*pass should be info:INFERRED_TYPE_CLOSURE*/([llll = /*info:INFERRED_TYPE_LITERAL*/const [1]]) => "hello";
+Function2<List<int>, String> g = /*pass should be info:INFERRED_TYPE_CLOSURE*/([/*info:INFERRED_TYPE*/llll = /*info:INFERRED_TYPE_LITERAL*/const [1]]) => "hello";
''');
}
@@ -1913,6 +1913,33 @@ foo() {
''');
}
+ void test_inferDefaultFormalParameter() {
+ var unit = checkFile('''
+f([/*info:INFERRED_TYPE*/x = 42]) {}
+g({/*info:INFERRED_TYPE*/x: 'hi'}) {}
+''');
+ expect(unit.functions[0].parameters[0].type.toString(), 'int');
+ expect(unit.functions[1].parameters[0].type.toString(), 'String');
+ }
+
+ void test_inferDefaultFormalParameter_fieldFormal() {
+ checkFile('''
+class C {
+ int x;
+ var y;
+ C({this.x: /*error:INVALID_ASSIGNMENT*/0.0, this.y: 'hi'}) {
+ String z = /*info:DYNAMIC_CAST*/y;
+ }
+ C.c([this.x =/*error:INVALID_ASSIGNMENT*/0.0, this.y = 'hi']) {
+ String z = /*info:DYNAMIC_CAST*/y;
+ }
+ m() {
+ String z = /*info:DYNAMIC_CAST*/y;
+ }
+}
+''');
+ }
+
void test_inferedType_usesSyntheticFunctionType() {
var mainUnit = checkFile('''
int f() => null;
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698