From 3af225ebb19364479ff09cc730c253f11eb80f68 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 25 Sep 2019 22:11:38 -0700 Subject: [PATCH 1/2] Update strict-inference re: return types of setters and overriding methods --- resources/type-system/strict-inference.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/resources/type-system/strict-inference.md b/resources/type-system/strict-inference.md index 04f65c1894..74cca291d2 100644 --- a/resources/type-system/strict-inference.md +++ b/resources/type-system/strict-inference.md @@ -297,12 +297,14 @@ void main() { ### Function return types -Declaring a recursive local function, a top-level function, a method, a -typedef, a generic function type, or a function-typed function parameter -without a return type is an inference failure. The return type of non-recursive -local functions can always be inferred from downwards or upwards inference, as -it will have a body, and the return type of the body is known (even if there -are inference failures within). +Declaring a recursive local function, a top-level function, a static method, a +non-overriding instance method, a typedef, a generic function type, or a +function-typed function parameter without a return type is an inference +failure. The return type of non-recursive local functions can always be +inferred from downwards or upwards inference, as it will have a body, and the +return type of the body is known (even if there are inference failures within). +Declaring a setter without a return type is allowed; the return type is assumed +to be void. ```dart f1() { // Inference failure @@ -320,9 +322,16 @@ void main() { class C { m1() => 7; // Inference failure + get g => 7; // Inference failure + int _s; + set s(int value) => _s = value; // OK (void assumed for setter) static m2() => 7; // Inference failure } +class D extends C { + m1() => 9; // OK (overrides C.m1) +} + typedef Callback1 = Function(int); // Inference failure typedef Callback2(int i); // Inference failure From 70aa2b86d1a48c6ffc62a8cea073851a39020b3c Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 17 Oct 2019 14:20:17 -0700 Subject: [PATCH 2/2] Fix typedef --- resources/type-system/strict-inference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/type-system/strict-inference.md b/resources/type-system/strict-inference.md index 74cca291d2..918906a706 100644 --- a/resources/type-system/strict-inference.md +++ b/resources/type-system/strict-inference.md @@ -298,7 +298,7 @@ void main() { ### Function return types Declaring a recursive local function, a top-level function, a static method, a -non-overriding instance method, a typedef, a generic function type, or a +non-overriding instance method, a type alias, a generic function type, or a function-typed function parameter without a return type is an inference failure. The return type of non-recursive local functions can always be inferred from downwards or upwards inference, as it will have a body, and the