Extends the illegal return type check for async functions to cover
illegal return types for functions marked async* or sync* as well.
Adds new error messages for illegal return types of functions marked
async, async*, and sync*. These error messages conform with those
produced by the analyzer.
Closes https://github.com/dart-lang/sdk/issues/33068
Bug: www.dartbug.com/33068
Change-Id: I6d8690537139d3d094a4e295fcac9de4f4a7f0af
Reviewed-on: https://dart-review.googlesource.com/69581
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
The scanner associates '<' with '>' and '>>',
but the parser cannot use '<'.endToken/endGroup reliably
and wastes time updating that token's endToken/endGroup field.
This CL updates type info parsing to ignore '<'.endGroup
and step through the token stream (which it has to do anyway),
for improved parsing.
This CL causes a handful of existing tests to fail (marked as @failingTest)
and test failures will be addressed in a subsequent CL.
Change-Id: I788e9a74cd2891f98f44bba15d5669febfec6c64
Reviewed-on: https://dart-review.googlesource.com/70001
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Fix for failing test language_2/final_field_initialization_order_test.
Bytecode generator was incorrectly omitting field initializer if
constructor also has initializer for that field.
Change-Id: I046231865677e1e59122d4d61b238e52b88003b7
Reviewed-on: https://dart-review.googlesource.com/70140
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
async function return type check whenever running in 'legacy mode'.
Adapts language_2_kernel.status such that a MissingCompileTimeError is
expected for illegal return types of async functions when running in
'legacy mode'. Updates the commentary in finishFunction in
body_builder.dart.
Some legacy tests* have revealed that it may not always be correct to
check whether [strongMode] is enabled before checking the return type of
async functions. The reason behind the strongMode check was to ensure
that [_typeInferrer.typeSchemaEnvironment] would be instantiated as
per ahe's suggestion.
There seems to be some inconsistency in the code base as to when
[_typeInferrer.typeSchemaEnvironment] is non-null. For example, during
the fasta perf benchmarks one may observe a null value, whilst it
seems that the member is always non-null when running `dart
--no-preview-dart-2 <script.dart>`.
* test log: https://ci.chromium.org/p/dart/builders/luci.dart.ci.sandbox/front-end-legacy-linux-release-x64/621
Change-Id: I2211bfe0ae75a7aa35e2d698ff5cba27af484d07
Bug: 33425
Reviewed-on: https://dart-review.googlesource.com/69920
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Instantiator type arguments are sometimes reused instead of doing
instantiation at run time. VM has a bunch of assertions to verify
that this optimization happened. In case of bytecode pipeline, decision
to reuse instantiator type arguments is done while generating bytecode.
For this optimization to correctly happen, bytecode generator
should be able to construct instantiator type arguments the same way
as VM does at run time. Besides flattening of type arguments of
superclasses, VM shrinks them by overlapping type parameters with
type arguments of a superclass (if they match). This CL implements
such overlapping in bytecode generator.
Also, --overlap_type_arguments VM option is removed, as disabling
of type arguments overlapping would break bytecode pipeline.
Change-Id: Ib276c0e688e0e86b44278d88a5c0af09dd342798
Reviewed-on: https://dart-review.googlesource.com/70060
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
These new classes are in lib/src to discourage them from being widely
used. The intention is to use them in angular_analyzer_plugin, so
that it can extend the wrapper classes rather than implement the
element classes directly. This will ensure that
angular_analyzer_plugin doesn't break when new methods are added to
element classes.
Change-Id: I33d82e4534691f546fcabc7b9d6c1da0258a5fc0
Reviewed-on: https://dart-review.googlesource.com/70020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This replaces calls to lt.endGroup when parsing type arg/param
with calls to computeTypeParamOrArg. This is a step towards
removing lt.endGroup everywhere and making type arg/param
parsing more resiliant and streamlined.
Change-Id: I5b3374769367f601c8910afa18116a2edd3f80c0
Reviewed-on: https://dart-review.googlesource.com/70000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
Now, instead of generating Symbol constant pool entries, bytecode generator
uses kernel-to-kernel constant evaluator to evaluate symbol literals.
Change-Id: I8dae4e388b6c1e8158ce39da792bb2e1cea2687a
Reviewed-on: https://dart-review.googlesource.com/69900
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
As TypeArguments == null means 'vector of all dynamic', VM uses special
object (Object::empty_type_arguments()) to indicate absence of
_Closure._delayed_type_arguments.
This CL corrects bytecode to use Object::empty_type_arguments() (via new
constant pool entry EmptyTypeArguments) to initialize
_Closure._delayed_type_arguments when allocating a closure.
Change-Id: I9b00bc0606de85c02350c8eef08d8952c3e224ee
Reviewed-on: https://dart-review.googlesource.com/69840
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This change improves type flow analysis to infer int types, in addition
to concrete classes (int type is abstract and has 2 concrete subclasses,
_Smi and _Mint).
Also, this CL enables devirtualization of dynamic calls (previously, only
calls with known interface target were devirtualized).
DartMicroBench.PrimeNumber:
x64: +221%
armv8: +461%
armv7h: +47.98%
No measurable impact on Flutter gallery build time in release mode.
Issue: https://github.com/flutter/flutter/issues/19677
Change-Id: I34db195f52f2a434218ee11eee7f308d4661738b
Reviewed-on: https://dart-review.googlesource.com/69520
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
I believe this was code only used via dart:mirrors
Soon we might want to rename JSInvocationMirror to just JsInvocation (so it's
clear that it is only used for nsm)
Change-Id: I0e0f836b18e6f290311c7173cfafedfcccab5c6f
Reviewed-on: https://dart-review.googlesource.com/69246
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Number of checked arguments is corrected in ICData objects created when
reading bytecode, both for instance and static calls.
InstanceCall1 and InstanceCall2 bytecode instructions are replaced with
InstanceCall which works for any number of checked arguments. This makes
decision on number of checked arguments internal to VM and it is no longer
exposed to bytecode.
Change-Id: I0bba01eca6347336f3832de863b2ce4715fda04a
Reviewed-on: https://dart-review.googlesource.com/69421
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
declared return type of an async function is a super type of Future<T>
for any T. In case the check is not successful an error message is
produced. The location of the name of the offending function
declaration is used as location information for message. Ideally we
would use the location of the type, so until types get annotated with
location information the error message remains suboptimal.
This closes#33425 and closes#34057.
Thanks to dmitryas and jensj for their helpful guidance.
Bug: dartbug.com/33425 dartbug.com/34057
Change-Id: I3b3dadc25b574422ea1f38671fe8cba3ffdd494c
Reviewed-on: https://dart-review.googlesource.com/69307
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
frontend_server uses getTarget - which means we need to call
installAdditionalTargets to ensure that flutter & vm targets are
properly installed.
Change-Id: I00a3d06f76c3bd31fe4e27e3947abea4c7883c44
Reviewed-on: https://dart-review.googlesource.com/69464
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
* Update named configs for unit tests to Dart 2.
* Bump json_rpc_2 in front_end package.
* Use named configurations in unit tests.
* Fix typing issues.
Change-Id: Id3b393a0d2abe92c8eaec10fa8057fb35d18a4c6
Reviewed-on: https://dart-review.googlesource.com/67341
Reviewed-by: Jens Johansen <jensj@google.com>
Code trying to run "pub upgrade" was blocked behind "runPub" being
false. Instead, expect the pub command to run. If the folder exists, run
"pub upgrade," and if it doesn't, run 'pub get'.
Change-Id: Ia37bf11d08e921e31d2ed4410210d03b8dbe1b00
Reviewed-on: https://dart-review.googlesource.com/69440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
This CL contains 2 fixes:
* Instantiator type arguments for factory constructors are calculated
using factory's type parameters and not class type parameters
(as factory's body uses factory's type parameters in kernel AST)
This improves reuse of instantiator type arguments in factory
constructors (optimization).
* Result of _AssertionError::_throwNew call is dropped off the stack.
Although control never returns from _throwNew, this fix is needed
to maintain correct stack balance while compiling bytecode.
Change-Id: Ib781b0d790a89576ef62b768513663e7e509749c
Reviewed-on: https://dart-review.googlesource.com/69384
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This is the first CL of several needed to fix typedef parsing
when there is no space between the type parameters and the `=`.
typedef F<T>= T Function(T);
* Fix some typedef parsing failures
* Add new consts for simple type var ending with ">>" and ">="
* Update computeType and computeTypeParamOrArg to return new consts
* Extract splitGtEq/GtGt/GtGtEq from splitEndGroup
* Hide internal TypeInfo and TypeParamOrArgInfo consts
Change-Id: Ice550f5b15df1f3cad616a2a342644974f14d8ee
Reviewed-on: https://dart-review.googlesource.com/69261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>