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

Issue 2456803004: fixes #27586, prefer context type in generic inference (Closed)

Created:
4 years, 1 month ago by Jennifer Messerly
Modified:
3 years, 9 months ago
Reviewers:
Leaf, vsm, keertip
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

fixes #27586, prefer downwards context type in generic inference fixes #27625, Object constraints were not tracked in inference fixes #27933, pin return type from downwards inference We now prefer to pick the bound (lower or upper) that had some information on, and it also improves inference error messages somewhat (still a ways to go). The way this works is we now have a type representing an unknown type: ?. We use ? when performing downward inference steps, instead of `dynamic`. This allows more accurate tracking of type constraints. For example: given: var x = await Future.wait([a, b]); Future.wait<T>'s argument type is Iterable<Future<T>>. Since we didn't know T, we previously pushed down Iterable<Future<dynamic>>. The dynamic caused loss of information. Now we push down Iterable<Future<?>>, allowing us to infer the right type there. R=leafp@google.com, vsm@google.com Committed: https://github.com/dart-lang/sdk/commit/f021a7019b0ba8515457d0bceb56af62273fb735

Patch Set 1 #

Patch Set 2 : fix #

Patch Set 3 : improvements #

Patch Set 4 : updates #

Patch Set 5 : fix ddc #

Patch Set 6 : more tweaks #

Total comments: 31

Patch Set 7 : fix gbind issue #

Patch Set 8 : fix for #27586, rebased against master #

Patch Set 9 : fix #

Total comments: 7

Patch Set 10 : fix #

Total comments: 1

Patch Set 11 : remove matchTypes #

Patch Set 12 : fix test #

Patch Set 13 : fix #

Patch Set 14 : fix #27933 #

Total comments: 8

Patch Set 15 : wip #

Total comments: 11

Patch Set 16 : merged #

Patch Set 17 : fix #

Total comments: 31

Patch Set 18 : fix #

Patch Set 19 : fix #

Patch Set 20 : fix #

Patch Set 21 : fix #

Total comments: 18

Patch Set 22 : fix downwards handling of ? in function expr #

Patch Set 23 : fix #

Total comments: 1

Patch Set 24 : address resolver.dart issue #

Patch Set 25 : fix #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1846 lines, -1163 lines) Patch
M pkg/analyzer/lib/src/dart/element/member.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +4 lines, -0 lines 0 comments Download
M pkg/analyzer/lib/src/dart/element/type.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +40 lines, -2 lines 0 comments Download
M pkg/analyzer/lib/src/error/codes.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M pkg/analyzer/lib/src/generated/resolver.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 21 chunks +146 lines, -269 lines 0 comments Download
M pkg/analyzer/lib/src/generated/static_type_analyzer.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 15 chunks +98 lines, -59 lines 0 comments Download
M pkg/analyzer/lib/src/generated/testing/test_type_provider.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 5 chunks +31 lines, -26 lines 0 comments Download
M pkg/analyzer/lib/src/generated/type_system.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 20 chunks +853 lines, -236 lines 0 comments Download
M pkg/analyzer/lib/src/summary/fasta/summary_builder.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M pkg/analyzer/lib/src/summary/link.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 chunks +11 lines, -9 lines 0 comments Download
M pkg/analyzer/test/generated/strong_mode_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 17 chunks +270 lines, -208 lines 0 comments Download
M pkg/analyzer/test/generated/type_system_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 8 chunks +50 lines, -13 lines 0 comments Download
M pkg/analyzer/test/src/summary/resynthesize_ast_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +15 lines, -0 lines 0 comments Download
M pkg/analyzer/test/src/task/strong/checker_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 7 chunks +19 lines, -24 lines 0 comments Download
M pkg/analyzer/test/src/task/strong/inferred_type_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 30 chunks +131 lines, -172 lines 0 comments Download
M pkg/dev_compiler/lib/sdk/ddc_sdk.sum View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Binary file 0 comments Download
M pkg/dev_compiler/lib/src/compiler/code_generator.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +4 lines, -3 lines 0 comments Download
M pkg/dev_compiler/test/browser/language_tests.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +4 lines, -1 line 0 comments Download
M pkg/dev_compiler/test/codegen_expected/map_keys.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +5 lines, -5 lines 0 comments Download
M pkg/dev_compiler/test/codegen_expected/map_keys.js.map View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M pkg/dev_compiler/test/codegen_expected/sunflower/sunflower.js.map View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M pkg/dev_compiler/test/codegen_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 chunks +2 lines, -7 lines 0 comments Download
M pkg/dev_compiler/tool/input_sdk/lib/html/dart2js/html_dart2js.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +4 lines, -4 lines 0 comments Download
M pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/types.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +29 lines, -17 lines 0 comments Download
M pkg/dev_compiler/tool/sdk_expected_errors.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +98 lines, -88 lines 0 comments Download
M tests/corelib_strong/set_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +2 lines, -2 lines 0 comments Download
M tests/language_strong/issue_23914_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +4 lines, -1 line 0 comments Download
M tests/language_strong/recursive_generic_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +5 lines, -3 lines 0 comments Download
M tests/language_strong/recursive_inheritance_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +10 lines, -5 lines 0 comments Download
M tests/lib_strong/html/documentfragment_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 19 20 21 22 23 24 1 chunk +2 lines, -1 line 0 comments Download
M tests/lib_strong/html/event_customevent_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M tests/lib_strong/html/js_typed_interop_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 19 20 21 22 23 24 1 chunk +2 lines, -1 line 0 comments Download
M tests/lib_strong/html/typing_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 18 19 20 21 22 23 24 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 36 (7 generated)
Jennifer Messerly
It might be worth going over this one in person, but sending it to you ...
4 years, 1 month ago (2016-10-29 01:12:30 UTC) #3
Jennifer Messerly
Hi Leaf, Vijay, here's the updated CL. I had to split out a few issues: ...
4 years ago (2016-11-30 03:29:42 UTC) #6
vsm
lgtm https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode4346 pkg/analyzer/lib/src/generated/resolver.dart:4346: //return UnknownInferredType.upperBoundForType(t); Did you mean to keep this ...
4 years ago (2016-11-30 04:05:33 UTC) #7
Jennifer Messerly
Thanks Vijay! BTW. I found a bug, it might be in DDC, I'm not sure ...
4 years ago (2016-11-30 04:35:04 UTC) #8
Jennifer Messerly
On 2016/11/30 04:35:04, Jennifer Messerly wrote: > Thanks Vijay! BTW. I found a bug, it ...
4 years ago (2016-11-30 04:43:28 UTC) #9
Leaf
lgtm https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode6177 pkg/analyzer/lib/src/generated/resolver.dart:6177: DartType rawType = classElement?.type; Comment here, just for ...
4 years ago (2016-11-30 05:24:30 UTC) #10
Jennifer Messerly
Thanks Leaf, I will go through these tomorrow! BTW for patch testing purposes, I've uploaded ...
4 years ago (2016-11-30 06:33:03 UTC) #12
Jennifer Messerly
Thanks all. I've uploaded a new version, re-testing. https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode6177 pkg/analyzer/lib/src/generated/resolver.dart:6177: DartType ...
4 years ago (2016-11-30 21:19:29 UTC) #13
Jennifer Messerly
would one of y'all mind PTAL on the test baselines? There are some changes due ...
4 years ago (2016-11-30 21:24:02 UTC) #14
vsm
lgtm https://codereview.chromium.org/2456803004/diff/160001/pkg/analyzer/test/src/task/strong/inferred_type_test.dart File pkg/analyzer/test/src/task/strong/inferred_type_test.dart (right): https://codereview.chromium.org/2456803004/diff/160001/pkg/analyzer/test/src/task/strong/inferred_type_test.dart#newcode662 pkg/analyzer/test/src/task/strong/inferred_type_test.dart:662: var b = new C<Object>(/*info:INFERRED_TYPE_LITERAL*/[123]); Is there any ...
4 years ago (2016-11-30 22:24:45 UTC) #15
Leaf
https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode6207 pkg/analyzer/lib/src/generated/resolver.dart:6207: if (contextTypes.isEmpty && On 2016/11/30 21:19:28, Jennifer Messerly wrote: ...
4 years ago (2016-12-01 04:36:27 UTC) #16
Jennifer Messerly
Hi Leaf, Here's the answer to the previous comments & another version that's passing. See ...
3 years, 11 months ago (2017-01-06 22:31:45 UTC) #17
Jennifer Messerly
https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode6207 pkg/analyzer/lib/src/generated/resolver.dart:6207: if (contextTypes.isEmpty && On 2017/01/06 22:31:45, Jennifer Messerly wrote: ...
3 years, 11 months ago (2017-01-11 02:24:38 UTC) #18
Jennifer Messerly
On 2017/01/11 02:24:38, Jennifer Messerly wrote: > https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart > File pkg/analyzer/lib/src/generated/resolver.dart (right): > > https://codereview.chromium.org/2456803004/diff/100001/pkg/analyzer/lib/src/generated/resolver.dart#newcode6207 ...
3 years, 11 months ago (2017-01-11 03:26:33 UTC) #19
Jennifer Messerly
On 2017/01/11 03:26:33, Jennifer Messerly wrote: > > ... and I'm now moving ahead on ...
3 years, 11 months ago (2017-01-12 22:26:08 UTC) #21
Leaf
Still looking at this, but calling it quits for tonight. couple of quick questions on ...
3 years, 11 months ago (2017-01-13 04:47:33 UTC) #22
Jennifer Messerly
Thanks Leaf, I've addressed these. I also backed out of the "take bounds into account ...
3 years, 11 months ago (2017-01-14 02:28:38 UTC) #23
Jennifer Messerly
On 2017/01/14 02:28:38, Jennifer Messerly wrote: > Thanks Leaf, I've addressed these. I also backed ...
3 years, 11 months ago (2017-01-17 20:22:10 UTC) #24
Leaf
First round of comments. See also https://codereview.chromium.org/2653833003/ . https://codereview.chromium.org/2456803004/diff/260001/pkg/analyzer/lib/src/generated/type_system.dart File pkg/analyzer/lib/src/generated/type_system.dart (right): https://codereview.chromium.org/2456803004/diff/260001/pkg/analyzer/lib/src/generated/type_system.dart#newcode1520 pkg/analyzer/lib/src/generated/type_system.dart:1520: /// ...
3 years, 11 months ago (2017-01-24 18:26:56 UTC) #25
Jennifer Messerly
Thanks Leaf. I've updated it. Interested to hear thoughts and chat about tomorrow? https://codereview.chromium.org/2456803004/diff/260001/pkg/analyzer/lib/src/generated/type_system.dart File ...
3 years, 10 months ago (2017-02-01 09:31:39 UTC) #26
Jennifer Messerly
https://codereview.chromium.org/2456803004/diff/280001/pkg/analyzer/lib/src/generated/type_system.dart File pkg/analyzer/lib/src/generated/type_system.dart (right): https://codereview.chromium.org/2456803004/diff/280001/pkg/analyzer/lib/src/generated/type_system.dart#newcode1603 pkg/analyzer/lib/src/generated/type_system.dart:1603: // <T extends Clonable<T>> On 2017/02/01 09:31:39, Jennifer Messerly ...
3 years, 10 months ago (2017-02-01 09:41:37 UTC) #27
Leaf
Round one of comments. https://codereview.chromium.org/2456803004/diff/320001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/320001/pkg/analyzer/lib/src/generated/resolver.dart#newcode4264 pkg/analyzer/lib/src/generated/resolver.dart:4264: // TODO(jmesserly): our downwards inference ...
3 years, 10 months ago (2017-02-17 06:41:22 UTC) #28
Leaf
Some more comments. At some point can you rebase and upload a branch to github? ...
3 years, 10 months ago (2017-02-17 22:26:04 UTC) #29
Jennifer Messerly
Thanks Leaf! I have a new & improved version if you could take a look ...
3 years, 9 months ago (2017-03-14 02:07:07 UTC) #30
Leaf
just a checkpoint of comments since you're preparing another patch set in parallel. https://codereview.chromium.org/2456803004/diff/370001/pkg/analyzer/lib/src/generated/resolver.dart File ...
3 years, 9 months ago (2017-03-14 22:37:40 UTC) #31
Jennifer Messerly
https://codereview.chromium.org/2456803004/diff/370001/pkg/analyzer/lib/src/generated/resolver.dart File pkg/analyzer/lib/src/generated/resolver.dart (right): https://codereview.chromium.org/2456803004/diff/370001/pkg/analyzer/lib/src/generated/resolver.dart#newcode4237 pkg/analyzer/lib/src/generated/resolver.dart:4237: * contains `?` this will be returned. You can ...
3 years, 9 months ago (2017-03-14 23:49:10 UTC) #32
Jennifer Messerly
https://codereview.chromium.org/2456803004/diff/370001/pkg/analyzer/lib/src/generated/type_system.dart File pkg/analyzer/lib/src/generated/type_system.dart (right): https://codereview.chromium.org/2456803004/diff/370001/pkg/analyzer/lib/src/generated/type_system.dart#newcode1595 pkg/analyzer/lib/src/generated/type_system.dart:1595: equals: (x, y) => x.location == y.location, On 2017/03/14 ...
3 years, 9 months ago (2017-03-14 23:55:16 UTC) #33
Leaf
Okay, i've got to call it a night. A couple of comments, but basically everything ...
3 years, 9 months ago (2017-03-15 00:27:13 UTC) #34
Jennifer Messerly
3 years, 9 months ago (2017-03-18 00:00:10 UTC) #36
Message was sent while issue was closed.
Committed patchset #25 (id:410001) manually as
f021a7019b0ba8515457d0bceb56af62273fb735 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698