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

Issue 2210293002: infer null from context, this avoids bottom being introduced (Closed)

Created:
4 years, 4 months ago by Jennifer Messerly
Modified:
4 years, 4 months ago
Reviewers:
Leaf
CC:
reviews_dartlang.org, stanm
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

infer null from context, this avoids bottom being introduced Note this regresses inference on ternary ops, so it may not be worth it

Patch Set 1 #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+47 lines, -23 lines) Patch
M pkg/analyzer/lib/src/generated/static_type_analyzer.dart View 1 chunk +12 lines, -2 lines 0 comments Download
M pkg/analyzer/test/generated/strong_mode_test.dart View 2 chunks +2 lines, -2 lines 3 comments Download
M pkg/analyzer/test/src/summary/resynthesize_ast_test.dart View 1 chunk +6 lines, -0 lines 0 comments Download
M pkg/analyzer/test/src/summary/summary_common.dart View 1 chunk +11 lines, -4 lines 0 comments Download
M pkg/analyzer/test/src/task/dart_test.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M pkg/analyzer/test/src/task/strong/inferred_type_test.dart View 10 chunks +13 lines, -12 lines 2 comments Download

Messages

Total messages: 4 (1 generated)
Jennifer Messerly
HI Leaf, wanted to get your opinion on this approach. I'm not sure it's a ...
4 years, 4 months ago (2016-08-04 13:10:16 UTC) #2
Leaf
Yeah, I think I agree that this isn't quite what we want yet. We might ...
4 years, 4 months ago (2016-08-04 23:52:55 UTC) #3
Jennifer Messerly
4 years, 4 months ago (2016-08-05 13:46:36 UTC) #4
Thanks for the sanity check. Worthwhile experiment but closing this out for now.

https://codereview.chromium.org/2210293002/diff/1/pkg/analyzer/test/generated...
File pkg/analyzer/test/generated/strong_mode_test.dart (right):

https://codereview.chromium.org/2210293002/diff/1/pkg/analyzer/test/generated...
pkg/analyzer/test/generated/strong_mode_test.dart:2049:
expectInitializerType('foo', 'dynamic', isNull);
On 2016/08/04 23:52:55, Leaf wrote:
> On 2016/08/04 13:10:16, John Messerly wrote:
> > This case is really unfortunate and makes me doubtful of the merits of this
> CL.
> > To some extent, it may be avoidable with null aware ops, but not always.
> > 
> > I suppose we could add some logic for ternary ops when one of the branches
is
> > null? Or is that just papering over the problem.
> 
> Yeah, I think this will cause problems.  I think it will show up in other
places
> that LUB is used as well.  I think there are ways we could tackle this, but
not
> sure it's worth it right now.

Yeah, definitely doesn't seem right at the moment.

Another thought here is define a type for `null` (maybe Null?), and have it be
subtype of other nullable types. essentially LUB(Null, T) becomes T in our
current system (and could be extended once we have non-nullable types).

But that's getting a little out of the scope of this change, so going to close
this one :)

https://codereview.chromium.org/2210293002/diff/1/pkg/analyzer/test/src/task/...
File pkg/analyzer/test/src/task/strong/inferred_type_test.dart (right):

https://codereview.chromium.org/2210293002/diff/1/pkg/analyzer/test/src/task/...
pkg/analyzer/test/src/task/strong/inferred_type_test.dart:2823: var y = (c.n *=
/*error:STATIC_TYPE_ERROR*/null);
On 2016/08/04 23:52:55, Leaf wrote:
> This doesn't seem right either.

yeah, this one could be fixed in a straightforward way though, I'm guessing we
just never felt the need to bother with a context type here.

Powered by Google App Engine
This is Rietveld 408576698