Commit Graph

35087 Commits

Author SHA1 Message Date
Paul Berry 0873d4eb82 Flow analysis: remove branchTarget() construct from unit tests.
Flow analysis unit tests now support implicit branch targets, and use
`LabeledStatement` directly in the case where the branch target is
explicit.  This is more similar to how the language acutally behaves,
and paves the way for adding more sophisticated tests in the future.

Note that at the moment, there are no flow analysis tests where a
`continue` statement has a different target than the innermost loop,
so for now, the `continue_` function doesn't accept a target
parameter.  I plan to add this functionality in the future, at the
time that I add tests that require it.

Change-Id: I2591ee3322ea4adba3e32dc76a29f0b3956058e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194040
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-05 12:19:07 +00:00
Konstantin Shcheglov 3ea23d2f55 Migrate pkg/analysis_server/test/integration/analysis/
Change-Id: I6dc636c06e13d1ac1da6caf2e33443baca08315d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194001
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-05 07:46:16 +00:00
Konstantin Shcheglov 1c25329091 Migrate more analysis_server/test/integration/ tests.
Change-Id: Idbcf7a7c628a61f23120013a113b35256c26ed25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194004
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-05 06:19:15 +00:00
Brian Wilkerson 23bee1698f Migrate the instrumentation log viewer tool
Change-Id: I2087c3c9d25cdf3266142ba57bb8dbc57bc3fc46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194002
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-05 05:11:45 +00:00
Konstantin Shcheglov f1fb297ad9 Migrate analysis_server/tool/spec
Change-Id: Ic8d7596198876d78f6628121ef0feb2fc9ea886d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194005
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-05 05:08:25 +00:00
Brian Wilkerson 99814617b0 Migrate more of server to null safety
Change-Id: I8989f5f9a45a9c832f0aeb56397fed978386ce30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194041
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-04 21:40:55 +00:00
Brian Wilkerson 34873853d8 Migrate some of the plugin support in server
Change-Id: I1294a33725ff0d0c3d2eb981c23211a8576f60f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194023
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-04 00:23:39 +00:00
Konstantin Shcheglov 454d4db340 Use Object as the type for TypeUnion in analysis_server protocol generator.
Change-Id: I6772182341df26211ff245748afb983e9d1b6ef4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194021
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 19:44:24 +00:00
Brian Wilkerson 0190d20bd6 Migrate some tests and test utilities in server
Change-Id: I0a37352c903bf7139af25aab255fe6a5331ce98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-03 19:23:44 +00:00
Konstantin Shcheglov 778c2361c3 Issue 45579. Report WRONG_NUMBER_OF_TYPE_ARGUMENTS and TYPE_ARGUMENT_NOT_MATCHING_BOUNDS.
Bug: https://github.com/dart-lang/sdk/issues/45579
Change-Id: I757f4d782895fb1a9c89d8238a7929e12d6a6eed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 17:46:16 +00:00
Paul Berry 2cfd6e421a Flow analysis: Use blocks internally in mini_ast representation.
For convenience in creating tests, the public mini_ast methods for
creating constructs like loops, try/catch, etc. accept lists of
statements as an argument where technically the language would expect
a single statement.  This CL changes the internal representation so
that each of these statement lists is converted into a single
statement by wrapping it in a block.

This makes the mini_ast representation more closely match the
representation used internally by the analyzer and CFE.

Change-Id: If2bf8a1cde694206b91b57c5907806b1965d4d99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193880
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 15:28:36 +00:00
Paul Berry 72bc3134c5 Unify "why not promoted" representations for for-loops and other writes.
This CL changes the responsibility for doing flow analysis of the
implicit variable write in a `for-in` loop as follows: if the `for-in`
loop does not declare a variable, but it assigns to a local variable,
then the flow analysis client is responsible for calling `write` on
entry to the loop.

This in turn allows us to use a single code path to track "why not
promoted" information related to all possible local variable writes;
we no longer need as much special case logic to handle for-in loops.

To make the analyzer integration slightly cleaner, we change the
argument type of FlowAnalysis.write to Node rather than Expression, so
that the analyzer can pass in the ForEachParts object when analyzing a
for-in loop.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I24b47be8eac2e276cd291a5b2f2e4444c911138f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193837
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 15:28:36 +00:00
Paul Berry 1cffb93ad7 Improve error message for non-promotion due to assignment.
This is clearer because:

- The use of "could not be promoted" is consistent with the other "why
  not promoted" messages.

- We avoid speculating about whether the variable might be assigned a
  null value; this should help avoid confusion in cases where the user
  can see that assigning a null value is impossible, but promotion
  still fails.

- We avoid the phrase "intervening write", which is a little too
  erudite.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I0b8a2132dc99dd06769677f98e6257e9b55ad9d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193820
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2021-04-03 13:43:36 +00:00
Konstantin Shcheglov a8590a287e Remove WithNonFunctionTypeAliasesMixin from analysis_server tests, enabled by default, update tests.
https://dart-review.googlesource.com/c/sdk/+/192948 was landed.

Change-Id: If5c175af47c9b324d6ca06597a4ebc3e3541cf85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 05:19:42 +00:00
Leaf Petersen 39a2e69ea4 Enable non-function type aliases by default in 2.13.
TEST=language/nonfunction-type-aliases

Change-Id: Ifff4e838fbfc4f71e2d990e1f1f8a67b987adf91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192948
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-04-03 01:31:42 +00:00
Konstantin Shcheglov 48c0eadb86 Migrate more of analysis_server_client
Added a few new methods to the listener, tests.

Change-Id: I477a17da3fd31db04c4960effee076680db62301
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193895
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-02 23:36:52 +00:00
Konstantin Shcheglov ada329f6b1 Use fields and field constructor initializers in generated protocol.
Change-Id: Ic361cd51b18a289d3a6062cfbab844366e41cefa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193886
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-02 22:41:22 +00:00
Brian Wilkerson 744fa0ba2d Migrate some additional libraries and their tests
Change-Id: I3aae14488fb5def205788a60b27d33211c88d330
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193889
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 20:02:22 +00:00
Brian Wilkerson 90d42351db Migrate a few more utilities to null safety
Change-Id: I2b623713ec3a7c366f6fe7643e7c56bab54f40a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193822
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-02 17:53:32 +00:00
Paul Berry 104e364b5c Flow analysis: in unit tests, look up property get types in harness.
This makes the flow analysis unit tests more similar to the behavior
of the analyzer and CFE, in that the types of various properties are a
property of the program being analyzed, not of the individual property
gets themselves.

Change-Id: I6ea164665093ee285325a64e80f3f52d7a63cf74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193836
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-02 17:38:42 +00:00
Nicholas Shahan eb2c982c15 [ddc] Optimize triple shift operations
Change-Id: Ib3c636ba9a36e427ca5209da6a1eba26e1e16e63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193746
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-04-02 17:10:52 +00:00
Stephen Adams 0087b0538b Revert "[dart2js] Implement Cell abstraction for late lowering."
This reverts commit b647020318.

Reason: test failures.
Change-Id: I1c4987ede89bebfcc5f14273f0bfbaf809507a43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193883
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-04-02 16:59:31 +00:00
Xavier H 9482dd6c6c Analyzer pkg: output required keyword in ToSourceVisitor
This fix `SimpleFormalParameter` in `ToSourceVisitor` to output `required` keyword

Closes https://github.com/dart-lang/sdk/pull/45561
https://github.com/dart-lang/sdk/pull/45561

GitOrigin-RevId: cbdf667aaa983258dd9b5da4323299732c056e72
Change-Id: I2abe0e34b832aed997df6c411b197a12e2f9023a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193839
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 16:31:42 +00:00
Brian Wilkerson 0f4943c22b Migrate some of the base test classes in server
Change-Id: I010389d51d519968ce7c1ecd8da8811d036d9ab2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193830
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 14:53:31 +00:00
Konstantin Shcheglov c2d660d161 Migrate analysis_server and analysis_server_client protocol.
Change-Id: Ie0912627733f0481de0d3239647a4978e5327f12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193641
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 06:46:41 +00:00
Stephen Adams db6f65e661 [dart2js] Avoid premature interceptor optimizations
Add a SsaFinalizeInterceptors phase that does optimizations with the
interceptor calling convention.

This puts the the caller and callee sides of the dummy explicit
receiver optimization in the same phase.

Change-Id: I07fe0483c2658c3744b76a235edb24720d7ea60f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193140
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-04-02 04:54:58 +00:00
Sam Rawlins 5e040a20f8 analyzer: Improve span of use_of_nullable_value errors
This changes the span reported from the _receiver_ to
the _use_ (method name, property name, operator token).

I think this change is overall an improvement.
Specifically, its a great improvement for cmdline
output, where the receiver and the "use" are on
different lines.

One possibly weird change is that if the operator is `[]`,
then I only highlight the `[` character. I don't know if
there is a better place, and I think this is fine.

Fixes https://github.com/dart-lang/sdk/issues/43708

Change-Id: Ie66ddf04b4904a367575193106385dd63ee39985
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188680
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 02:43:48 +00:00
Ben Konyi 628193450a [ CLI ] Check for valid package names and '.' when creating new projects
Ensures that Dart projects created using 'dart create' are valid
packages.

Fixes https://github.com/dart-lang/sdk/issues/43216.

Change-Id: I1e38ba722f24a247e64f077d35c8e74c051c4908
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193825
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-04-01 23:58:47 +00:00
Mayank Patke b647020318 [dart2js] Implement Cell abstraction for late lowering.
Change-Id: Ib5fe8ed8e43513283a4e05f216e068241e8d63da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193587
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-04-01 23:57:27 +00:00
Mayank Patke 76ed8441b9 Add frontend expectations for late variables in dart2js.
Change-Id: I718ba69d31d44f30bb52157e87ebc64316bf860b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193586
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-04-01 22:58:07 +00:00
Joshua Litt d5f3189c91 [dart2js] Extends the graph_isomorphizer with more coverage.
This cl adds support for generating classes, classes used only for
types, mixins, closures, and constants, to the graph_isomorphizer.

Change-Id: I04e5590a9ff903b0b32daf1f4607fb1b0920e0cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189841
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-04-01 17:06:52 +00:00
Paul Berry c25e74852c Add links to "why not promoted" error messages.
These links are not live yet, but they will be filled in with
documentation explaining subtleties of type promotion in more detail.

Bug: https://github.com/dart-lang/sdk/issues/44900
Change-Id: I3e1865597fc5c56495a8108c8a4de98cab0c3e4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193749
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-01 16:42:12 +00:00
Dmitry Stefantsov 904882fce3 [cfe] Check rhs of typedefs for regular-boundness
Closes #42435.
Closes #45491.
Closes #45493.

Bug: https://github.com/dart-lang/sdk/issues/42435
Bug: https://github.com/dart-lang/sdk/issues/45491
Bug: https://github.com/dart-lang/sdk/issues/45493
Change-Id: I368aff553a8bdd5e5312ecf06f0d19c8390a0d22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193662
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-04-01 12:26:43 +00:00
Konstantin Shcheglov e673c19820 Resolve annotations via type aliases.
Change-Id: I6d22e06775d31856fc85a350892efe15208832f5
Bug: https://github.com/dart-lang/sdk/issues/44838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193743
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-01 02:52:43 +00:00
Paul Berry 4d696edc97 Fix static error test handling of duplicate context messages.
It can sometimes happen that multiple error messages point to equal
context messages.  To prevent the static error test runner from
getting them mixed up, we need to use identity maps to track the
mapping from error message to context number.

Change-Id: I6d03484a37519d5db1f92750273daf898cb4381a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193527
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2021-03-31 23:03:22 +00:00
Dmitry Stefantsov 19297a9a42 [cfe] Implement missing bound checks for nonfunction type aliases
Closes #45519.

Bug: https://github.com/dart-lang/sdk/issues/45519
Change-Id: I0492e83ebf605eaa1355d7e472bc28050dc5588c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193500
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-31 19:21:42 +00:00
Devon Carew bfaed5e927 Update the text for the 'in file' version of a fix.
Change-Id: If9263f567acd20d377bf661f65f051d468f4eadd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193721
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-03-31 18:04:29 +00:00
Paul Berry 0e8a84173e Migration: fix futures using .then rather than as
Previously, if the migration tool encountered a Future expression with
a bad type (e.g. a Future<String?> where a Future<String> was needed),
it would "fix" the problem by introducing a cast.  That is nearly
always the wrong thing to do; what we want to do is null check the
value that the future *completes* with.

This CL changes the migration tool so that it fixes this case by
appending `.then((value) => value!)` to the future expression.

Fixes #45472.

Bug: https://github.com/dart-lang/sdk/issues/45472
Change-Id: I7a35b54f673936e2e4b0f8f3a077ba8bf684b4eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-31 17:48:19 +00:00
Joshua Litt 5ca3b45541 [dart2js] Remove unused 'classesOnlyNeededForRti' field.
Change-Id: I424fd9fcf6c7f8a9d0f724b5599fc96242bb9042
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192943
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-03-31 17:30:29 +00:00
Johnni Winther 3c2dfd7975 [cfe] Check bounds on function invocation
Closes #45464

Change-Id: I0fb3abf66c2119147ddd9413792e6f5dc151c31c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-31 16:33:49 +00:00
Konstantin Shcheglov fd63463daf Don't create additional ContextRoot(s) when nested in an existing root.
Change-Id: I52a0b4f32b7d84d3c3287f94a6e4d7c488374a35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193528
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-31 16:14:59 +00:00
Joshua Litt 81092839c7 Reland "[dart2js] Avoid reserializing the closed world alongside type inference."
This is a reland of 7b022a7f2f

Original change's description:
> [dart2js] Avoid reserializing the closed world alongside type inference.
>
> This cl adds a temporary flag '--no-closed-world-in-data' in order to
> support serializing global inference results with and without the closed
> world.
>
> This flag only exists to allow us to roll this into google3. Afterwards,
> it will be removed.
>
> Change-Id: I6e9712739edd148edcf43007b6ece35efa688538
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192124
> Commit-Queue: Joshua Litt <joshualitt@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I47c08edb868f272c7501ae139a9533fa07d4176f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193585
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2021-03-31 16:11:39 +00:00
Alexander Markov 303f1eda70 [vm/aot] Avoid reusing Reference when replacing Field with getter in tree shaker
TEST=existing tests
Change-Id: I0a661e8d1b0be418080dadfe4ffe1eabd49a16aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-31 15:57:59 +00:00
Alexander Markov 6239c434fb [vm,cfe] Avoid elimination of 'x as Function' type casts
Elimination of redundant type cast 'x as Function' where x is
a function type (such as 'void Function(int)') is not correct because
it changes semantics of a function call if such expression is
used as a receiver.

"Function" static type of receiver allows arbitrary function calls,
while known function type of the receiver means the call doesn't
need to check parameter types. Static type of receiver is currently
not stored in kernel AST but calculated from the receiver node,
so replacing 'x as Function' with 'x' changes static type of
the receiver from "Function" to function type.

TEST=tests/language/regress/regress45428_test.dart
Fixes https://github.com/dart-lang/sdk/issues/45428

Change-Id: If7148450526703daa63a442adf67a9e7a2dcea54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193524
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-03-31 15:57:29 +00:00
Paul Berry e4fbad8744 Flow analysis: fix "why not promoted" info for nullable_expression_call_error
Previously, I only did the proper flow analysis integration in the
case where `useNewMethodInvocationEncoding` was true, so these cases
didn't work when it was false.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I6e126f4b8dc9a159087669c3d6ffa332373f8ce4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193590
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-31 15:20:28 +00:00
Paul Berry 10d531b5f9 Flow analysis: Minor fixes to "why not promoted" ID tests.
The ID tests for the "why not promoted" feature had some minor
unintentional errors in them.  This CL fixes them:

- The constructor tests in
  argument_type_not_assignable_nullability_error.dart tried to return
  null from functions whose return type didn't allow it.

- The compoundAssignmentRhs test in
  argument_type_not_assignable_nullability_error.dart tried to add an
  `int` to an `int?`.  The CFE considers this to be an error, but also
  reports a follow-on error because it thinks the type of the
  resulting expression is `num` (which is not assignable back to
  `int`).  To avoid the follow-on error, we use `num` for the type of
  the variable to which compound assignment is being applied.

- The forElementInMap test in
  for_in_loop_type_not_iterable_nullability_error.dart wasn't a proper
  map (it contained two `null` elements, rather than a single map
  entry `null: null`, which was what was intended).

There were also several tests for which we *don't* expect "why not
promoted" information; I added comments explaining why.

Change-Id: I91ddb88cb0f25f9b209df3eeb75d57d8270f877b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193561
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-31 15:20:28 +00:00
Johnni Winther 1eda15854d [cfe] Allow experiments only in current sdk version
Experiments that have not be enabled by default should only be allowed
in the current version of the sdk.

Closes #45460

Change-Id: I159f390ac85fe37943920717ce11a4c817d5b4a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193480
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-31 15:20:08 +00:00
Johnni Winther 19ab1fd800 [cfe] Report error on nullable supertypes through type aliases
Closes #43261
Closes #45423

Change-Id: Ia22975f9cd8fd3835b0feda82c6d5310098b605c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193501
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-31 12:34:13 +00:00
Johnni Winther 9ca19cac6f [kernel] Change encoding of types in constants to not be offset by the context
Function type parameters in occurring in constants were using an offset
based on the context in which the constant first occurred. This meant
that function type parameters occurring in a generic context would have
a different offset that those occurring in a non-generic context.

The loading of .dill in ast_from_binary would read all constants outside
the context and would therefore get the indices wrong on generic
function types.

This CL changes the encoding of these type parameters to always use
a fresh context.

Closes #45415

TEST=pkg/front_end/testcases/generic_metadata/from_dill/main.dart

Change-Id: Ifdaedb4581f1e022c908fc58a58ceac3d7b0900e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193481
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-03-31 12:31:43 +00:00
Brian Wilkerson 628e630ca2 Convert a few utility libraries to null safety
Change-Id: I1e1cde29a40eb498d8e25c72189641d568d7db03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193591
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-03-31 05:45:32 +00:00