This CL fixes two minor flaws in the type inference of closure return types:
- inferReturnType needs to call _wrapAsyncOrGenerator prior to
checking whether the inferred return type is a subtype of the
context. This is necessary because for async and generator
functions, the context type is the "wrapped" type (FutureOr<>,
Iterable<>, or Stream<>).
- _updateInferredReturnType needs to perform implicit downcasts before
storing the inferred return type. This is necessary because if in
implicit downcast is added, the inferred type that should be stored
is the type that was downcast to. In order to make this work, the
"unwrapping" logic needed to be moved from
_updateInferredReturnType's two call sites into
_updateInferredReturnType itself.
These flaws were benign because they were masked by the looseness of
the future flattening operation. They need to be fixed so that future
flattening can be made more precise.
Change-Id: I2b5ea3f63632638b5fadbce7d52c5d028acda5ab
Reviewed-on: https://dart-review.googlesource.com/34480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This linked in kernel service dill file will be used to load the kernel
isolate if the attempt to lookup the kernel service snapshot fails. The
kernel service snapshot is looked up in the following order.
1. If the "--dfe" option is specified, the file specified is used.
2. If the kernel service snapshot is found next to the executable,
then it is used.
3. If the kernel service snapshot is found in the "snapshots" directory
next to the executable, then it is used.
Change-Id: I5a0e757eb27b26a274b22b4bc36350fee59a100f
Reviewed-on: https://dart-review.googlesource.com/32446
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Chandra <sivachandra@google.com>
A fairly internal case, so I ended up guarding it semi-heavily with
asserts, which could go against convention, but seems fairly safe here.
Two tests: One that sanity checks some edge cases & exemplary values,
and another one that checks each combination programmatically. Together
they should be the best coverage; both the reliance of computers and
the simplicity of specific cases.
Should be very easy to pop in the void type here next.
Bug: 28513
Change-Id: Id20811a77b4de3f2c4ede7a77e1da5a114432e97
Reviewed-on: https://dart-review.googlesource.com/34305
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
- closed world is incomplete anyway; we're missing the call methods from static and instance tear-off.
Change-Id: Ibd3fc9d80220bef3ee651bf529a487b617de7a6b
Reviewed-on: https://dart-review.googlesource.com/34144
Reviewed-by: Sigmund Cherem <sigmund@google.com>
In addition to updating test expectations, this CL also
* Streamlines parsing modifiers in 2 places
* Addresses comment in https://dart-review.googlesource.com/c/sdk/+/33500
Change-Id: Ia3d4b7db8a908455b533c1360d107d3557fbb36f
Reviewed-on: https://dart-review.googlesource.com/34200
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
solves the generic function type scoping problem (fixes the test).
Includes further failures documented here:
https://github.com/dart-lang/sdk/issues/31804 with @failingTests.
These do seem to fail today as is, so it should be safe to land.
Bug:
Change-Id: Ice384b6fee35f1b1c4235bb0e4de7a90e2379937
Reviewed-on: https://dart-review.googlesource.com/33582
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Global type flow analysis is a whole-program type inference on
strong-mode kernel AST which is aimed at inferring various properties
useful for optimizations, such as non-nullability, exact types and
monomorphic call targets.
Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ie2e6e642dfacdb562a3341f8d2bbaf69ca829319
Reviewed-on: https://dart-review.googlesource.com/30903
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
See #31649 for more details about forwarding semi-stubs.
Change-Id: Iaf1153be5ac7f66503b93a362b66ac9585462f6c
Reviewed-on: https://dart-review.googlesource.com/33820
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Change-Id: I5ebf49427ac4ddd005c490d1f04880f005211d26
Reviewed-on: https://dart-review.googlesource.com/33943
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Change-Id: I656880ceb89bfe3e5588d035d2c1a452580c2e95
Reviewed-on: https://dart-review.googlesource.com/34104
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Preparation for data URI support. For clarity, this is just a rename.
Change-Id: Ibbd8da05d1a7106b5ec7c0ea9c1e13a95a89d1bd
Reviewed-on: https://dart-review.googlesource.com/33460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Issue 28698 updated 3 status file entries. 2 entries are now gone,
and the last one doesn't seem to be current anymore.
This CL removes the remaining - unnecessary - entry.
Bug:
Change-Id: I38c8339e83c00d4be33ce84abc1c12f0b5ebe181
Reviewed-on: https://dart-review.googlesource.com/32771
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Directory.current.path on Windows uses "\" and not "/" and does not
start with a slash.
Bug:
Change-Id: Id1b75ee0e3962c3531ba964aee9300025cdbcdca
Reviewed-on: https://dart-review.googlesource.com/34101
Reviewed-by: Jens Johansen <jensj@google.com>
Directory.current.path on Windows uses "\" and not "/".
Bug:
Change-Id: I6ef789d586622f78d0401c1a892f6a475bf6d93a
Reviewed-on: https://dart-review.googlesource.com/34100
Reviewed-by: Jens Johansen <jensj@google.com>
- Added JS_GET_FLAG('STRONG_MODE') allow the code to be tailored to
the type system version.
- Split type stringifying code into V1 (existing logic) and V2
(strong mode Dart 2.0 logic).
The V1 code will eventually be deleted.
Change-Id: I78db91796040b6ecfa1bd5d6a9d64bd4c2bc4bcf
Reviewed-on: https://dart-review.googlesource.com/33680
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This CL extracts parsing modifiers from parsing types so that
parseModifiers just parses modifiers and a separate call is made
to parseType.
* Discard the ModifierContext object sooner
* Remove some places where findMemberName output was being
used to determine which modifiers are present.
Currently, modifiers are parsed once by findMemberName,
again by parseModifiers, and sometimes a third time
by isFactoryDeclaration. This CL sets the stage for
improved modifier recovery and parsing modifiers exactly once.
Change-Id: Ieb8cd1156ed090ca4653258bd40afbac843b9b7c
Reviewed-on: https://dart-review.googlesource.com/33500
Reviewed-by: Peter von der Ahé <ahe@google.com>
Change-Id: I59764334cb1befda9e0db0fd09fc83f6398f61da
Reviewed-on: https://dart-review.googlesource.com/32960
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
This revision has been factored out of Revision 29300.
Change-Id: Idf579f0e5ffeea5764e2a9654c6812d69f6977c7
Reviewed-on: https://dart-review.googlesource.com/31921
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Change-Id: I28623bed9d5d203e82d50c4b057803a89e76757d
Reviewed-on: https://dart-review.googlesource.com/33380
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
Add Observatory test to check debug positions for e.g. a[0]().
Non-kernel pipeline points to '(', whereas the (old) kernel behaviour
was to point to 'a'. This fixes the kernel behaviour to also point to '('.
Bug:
Change-Id: I9cd0a2f0cdd4428cd491d02ccc63c72caf285292
Reviewed-on: https://dart-review.googlesource.com/31982
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
suppress a hint on undefined imported name to make it backwards
compatible.
Bug:
Change-Id: I9c92adcf685248fb8aae9da39c008968768ad29b
Reviewed-on: https://dart-review.googlesource.com/33662
Reviewed-by: Paul Berry <paulberry@google.com>
suppress hints about the undefined name for backwards compatibility.
Bug:
Change-Id: I381af6a8ae5be040e3c149e0cf4b9d45faa8c630
Reviewed-on: https://dart-review.googlesource.com/33663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
This is based on https://dart-review.googlesource.com/c/sdk/+/20481/10,
which required a rollback due to numerous secondary revealed issues.
Rather than deserializing function types with the proper scope, and
breaking inherited function type params, ie, `m(x)` where `x`
implicitly gets the type of `x` from `super.m(... x)`, deserialize
generic types incorrectly so that `const x = <Function<T>(T)>[]` fails
but `m(x)` works.
I have work towards fixing this issue, but it is incomplete (#31804),
and had to be rolled back and the fix is only getting more tangled:
https://dart-review.googlesource.com/c/sdk/+/33582.
For now, this will allow people to use Function types *without* type
parameters with no issues, and introduce no secondary issues, and
hopefully be a more straightforward change in and of itself.
-- From Rolled Back CL --
Remove field formal parameter test from other branch
Test genericFunctionType summarization deeper: params, return.
Didn't see a standard way of testing 'void' in the test so far, so I
followed some other tests and used isNotNull, which could be improved.
Fix type arguments vs parameters.
Fix#30858, generic function types not serializable when const.
Previously declaring for instance const lists (or even final lists) of
generic function types ie `final x = <void Function()>[]` would throw
errors during summarization.
The type parameters don't seem correctly stored yet, but that is an
edge case. Left a TODO, for now this should go in to prevent the
analyzer crash.
One thing I changed as well is that `serializeType` assumed it was
getting a type name, and `serializeTypeName` accepted types but threw
when it didn't get a type name. I flipped the names so that
`serializeTypeName` accepts a type name and `serializeType` accepts a
type in general and decides whether its a type name or a generic
function type to proceed with specialization.
Bug:
Change-Id: I98f5a362c9b2e8b3a7e87532ff4645b5963277ab
Reviewed-on: https://dart-review.googlesource.com/33660
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This also adds the missing vm-kernel opt-counter builder.
Bug: https://github.com/dart-lang/sdk/issues/31753
Change-Id: I0199218f83d227cfc52505c213d7b689acd9c43e
Reviewed-on: https://dart-review.googlesource.com/31984
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
new errors since the parameter type inference logic was changed:
analyzing pkg/analyzer...
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:174:16 •
inconsistent_method_inheritance
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:262:16 •
inconsistent_method_inheritance
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:315:16 •
inconsistent_method_inheritance
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:467:16 •
inconsistent_method_inheritance
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:488:16 •
inconsistent_method_inheritance
error • Inconsistent declarations of 'getAncestor' are inherited from
<E>(dynamic) → E, <E extends Element>((Element) → bool) → E at
pkg/analyzer/lib/src/fasta/mock_element.dart:501:16 •
inconsistent_method_inheritance
6 errors found.
Bug:
Change-Id: I48b98e287bd6496b0745a1fcb42f87450cbfba9c
Reviewed-on: https://dart-review.googlesource.com/33180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
This only works for inlining of dynamic methods. Stubs are not created yet.
Change-Id: Ia138117d503b69774984ce9070a3298b87fdbe78
Reviewed-on: https://dart-review.googlesource.com/32766
Reviewed-by: Sigmund Cherem <sigmund@google.com>
For instance, with the program snippet from issue #31409 one would not
get any other output than the errors, and one would have to explicitly
dump the dill file afterwards to see what was actually generated.
This CL changes this, so the error-library is also printed (in addition
to the, at least in the case of issue #31409, empty list) as in
```
$ pkg/front_end/tool/fasta compile tmp.dart --dump-ir
tmp.dart:2:4: Error: Expected a function body or '=>'.
Try adding {}.
V();
^
tmp.dart:3:5: Error: Duplicated definition of 'V'.
var V;
^
tmp.dart: Error: Duplicated name: 'V'.
tmp.dart:2:1: Error: Duplicated name: V
V();
^
library;
import self as self;
static method #main() → dynamic {
throw "tmp.dart:2:1: Error: Duplicated name: V\nV();\n^";
}
```
Bug:
Change-Id: I8739be43137f098e6dc50df27f4d1d8628bea469
Reviewed-on: https://dart-review.googlesource.com/32602
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
It seems that f99d3628d1
(CL https://dart-review.googlesource.com/33144)
caused these 5 tests to time out on the pkg builder as well as the try
bots.
Locally the tests take ~40 seconds, so giving it a bit more time (i.e.
marking them as slow) seems likely to turn things green again.
Bug:
Change-Id: I90526b1d7060309d8f1cf902bd9d52c71927f1ed
Reviewed-on: https://dart-review.googlesource.com/33340
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Before we used a hack to request resolution information for a single
library as needed, and requested kernels separately. This was hugely
inefficient (but faster to implement as a steel thread). We had then
recompile large library cycles many times, and take just one library.
Before: 480 seconds to compile analyzer (ouch!).
Now: 16 seconds (30 times faster).
Without --previewDart2: 14 seconds.
I will check why it is still slower later.
R=brianwilkerson@google.com, paulberry@google.com
Bug:
Change-Id: Ic3d47684daa74c53f0336523e17b656f26328acf
Reviewed-on: https://dart-review.googlesource.com/33144
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This reverts commit 60ee2c0dcd.
Reason for revert: Requires https://dart-review.googlesource.com/c/sdk/+/33180 which can land first.
Original change's description:
> Fix#30858, generic function types not serializable when const.
>
> Previously declaring for instance const lists (or even final lists) of
> generic function types ie `final x = <void Function()>[]` would throw
> errors during summarization.
>
> The type parameters don't seem correctly stored yet, but that is an
> edge case. Left a TODO, for now this should go in to prevent the
> analyzer crash.
>
> One thing I changed as well is that `serializeType` assumed it was
> getting a type name, and `serializeTypeName` accepted types but threw
> when it didn't get a type name. I flipped the names so that
> `serializeTypeName` accepts a type name and `serializeType` accepts a
> type in general and decides whether its a type name or a generic
> function type to proceed with specialization.
>
> Bug: 30858
> Change-Id: Id128f8625cbf03bb94d05ff0efdbac3b158e637e
> Reviewed-on: https://dart-review.googlesource.com/20481
> Reviewed-by: Paul Berry <paulberry@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
TBR=paulberry@google.com,scheglov@google.com,mfairhurst@google.com
Change-Id: I6fae28335f7815b1e8c43597fb9451519a13335e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 30858
Reviewed-on: https://dart-review.googlesource.com/33200
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Previously declaring for instance const lists (or even final lists) of
generic function types ie `final x = <void Function()>[]` would throw
errors during summarization.
The type parameters don't seem correctly stored yet, but that is an
edge case. Left a TODO, for now this should go in to prevent the
analyzer crash.
One thing I changed as well is that `serializeType` assumed it was
getting a type name, and `serializeTypeName` accepted types but threw
when it didn't get a type name. I flipped the names so that
`serializeTypeName` accepts a type name and `serializeType` accepts a
type in general and decides whether its a type name or a generic
function type to proceed with specialization.
Bug: 30858
Change-Id: Id128f8625cbf03bb94d05ff0efdbac3b158e637e
Reviewed-on: https://dart-review.googlesource.com/20481
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Test failures introduced by this change have been marked with issue #31616.
Change-Id: Id82a2e850d2d7c3ebcb78b5acb2e59ea3d8da544
Reviewed-on: https://dart-review.googlesource.com/32682
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reland of https://dart-review.googlesource.com/c/sdk/+/29160
Adds a 'severity' field to diagnostic messages and replaces all
addWarning and addNit functions by a generic addProblem, which uses
the intrinsic severity of the message. Eventually, errors should
also be reported this way.
A special severity value maps into either warning or error for Dart 1
and Dart 2, respectively. Most Dart 1 warnings are in this category.
Fixes some 320 failures of DDK test expecting a compile-time error.
These were previously masked by a workaround in the DDC error handler
which has now been removed.
Closes https://github.com/dart-lang/sdk/issues/31286
Change-Id: Id3b3b7f1fc6a101639fc908c90f3ec7d304a7b4b
Reviewed-on: https://dart-review.googlesource.com/32580
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Note that the annotation "/*@target=C::aField*/" is duplicated in the
test due to #31790.
Change-Id: Ie3cf2dea7efb9ae46310ee069a588feb37855201
Reviewed-on: https://dart-review.googlesource.com/32862
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This required some changes to analysis_server, since analysis_server
used to have its own version of pumpEventQueue(). Since
pumpEventQueue() is now provided by the test package, I've removed
analysis_server's version, and I've updated some of the call sites to
pass in "times: 5000" to replicate the old analysis_server behavior.
This also required some changes to analyzer, since the fail() method
is now marked as @alwaysThrows, so no code may follow it without
producing a dead code hint.
Change-Id: Ie5ef3a5cc685c18da02de699e59f63f3bb8865f7
Reviewed-on: https://dart-review.googlesource.com/32683
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This reverts commit ab229b30ef.
Reason for revert: Failing co19 test
Original change's description:
> Improve fasta field recovery
>
> In addition to improving field recovery, this CL
> fixes class field recovery to include an endMember event event
> and cleans up missing class body recovery.
>
> Change-Id: I53afe5aef55452108803388de9245f7e14f97833
> Reviewed-on: https://dart-review.googlesource.com/32820
> Commit-Queue: Dan Rubel <danrubel@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
TBR=brianwilkerson@google.com,danrubel@google.com
Change-Id: Id2976bfe67b410875a912bbfd6bfcbbe3d3c8c75
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/32840
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
In addition to improving field recovery, this CL
fixes class field recovery to include an endMember event event
and cleans up missing class body recovery.
Change-Id: I53afe5aef55452108803388de9245f7e14f97833
Reviewed-on: https://dart-review.googlesource.com/32820
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The constant collector was inconsistent with the old frontend: we were
skipping primitives and we were not going into the body of closures.
Change-Id: I3321426da7e684d203f0ac7a2a2c7028f3138a7b
Reviewed-on: https://dart-review.googlesource.com/32663
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Emily Fortuna <efortuna@google.com>
'Normalize' the data used for loading deferred libraries. Replace
URIs and SHA1 hashes with indexes so that the URIs and hashes occur
once.
Bug: https://github.com/dart-lang/sdk/issues/29635
Change-Id: I3ac8791ad44ca588cbb1bd7d86f18243c956a04a
Reviewed-on: https://dart-review.googlesource.com/32505
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Also adds this to the build script, so we can eventually replace the existing SDK compile step with this new one.
Change-Id: Iba0720df5bbab302d2fdd0b5aeeb182de152cc98
Reviewed-on: https://dart-review.googlesource.com/32504
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>