Commit Graph

362 Commits

Author SHA1 Message Date
Johnni Winther 8103c90dbf [cfe] Use combined member signature in override inference in legacy code
+ emit only one message per method given that it now always has the
same root cause, namely that the combined member signature does not
exist.

Closes #31797

Change-Id: Id89a5557c5fdda1db087c20cbe92847dd08216a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175305
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-09 17:33:20 +00:00
Paul Berry a7ee05f27d Reland "Flow analysis: Track expression variables separately from promotion info."
This is a reland of fd2a6c6815

Original change's description:
> Flow analysis: Track expression variables separately from promotion info.
>
> Previously, we used a single class hierarchy, ExpressionInfo, to store
> all the information that flow analysis needs to know about a variable,
> including:
>
> 1. What is known about the program state if the expression evaluates
>    to true/false
>
> 2. Whether the expression is a `null` literal
>
> 3. Whether the expression is a reference to a variable.
>
> However, in order to address
> https://github.com/dart-lang/language/issues/1274 (Infer
> non-nullability from local boolean variables), we'll need #3 to be
> tracked orthogonally from #1, so that when a local boolean is referred
> to later, we can track information of type #1 and #3 simultaneously.
>
> However, it makes sense to keep #1 and #2 in the same data structure,
> because future work is planned to represent them in a more uniform
> way, as part of addressing
> https://github.com/dart-lang/language/issues/1224 (Using `if (foo?.bar
> == somethingNotNull)` should promote `foo`).
>
> Change-Id: I432f6e2e80543bb1d565b49403180c520eef66a5
> Bug: https://github.com/dart-lang/language/issues/1274
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175008
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

Bug: https://github.com/dart-lang/language/issues/1274
Change-Id: I002adbde782887def50dc80ab6673411b321c341
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175362
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-09 14:36:50 +00:00
Jens Johansen c60398400e [parser] Recover better from 'required' parameter declaration in non-nnbd
Natural follow-up to https://github.com/dart-lang/sdk/issues/44379.

Change-Id: Idf73df0c9e8ce1f477d05aa73caf8975d2ffb9f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175307
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-09 13:47:19 +00:00
Jens Johansen a8b372057e [parser] Recover better from 'late' field/variable declaration in non-nnbd
Fixes #44379
(https://github.com/dart-lang/sdk/issues/44379)

Change-Id: If97d0d57b1fe16777f6208b49a8b472420ac526a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175306
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-09 13:01:39 +00:00
Paul Berry 2d8e5a6a02 Revert "Flow analysis: Track expression variables separately from promotion info."
This reverts commit fd2a6c6815.

Reason for revert: Broke pkg/dds/test/sse_smoke_test

Original change's description:
> Flow analysis: Track expression variables separately from promotion info.
>
> Previously, we used a single class hierarchy, ExpressionInfo, to store
> all the information that flow analysis needs to know about a variable,
> including:
>
> 1. What is known about the program state if the expression evaluates
>    to true/false
>
> 2. Whether the expression is a `null` literal
>
> 3. Whether the expression is a reference to a variable.
>
> However, in order to address
> https://github.com/dart-lang/language/issues/1274 (Infer
> non-nullability from local boolean variables), we'll need #3 to be
> tracked orthogonally from #1, so that when a local boolean is referred
> to later, we can track information of type #1 and #3 simultaneously.
>
> However, it makes sense to keep #1 and #2 in the same data structure,
> because future work is planned to represent them in a more uniform
> way, as part of addressing
> https://github.com/dart-lang/language/issues/1224 (Using `if (foo?.bar
> == somethingNotNull)` should promote `foo`).
>
> Change-Id: I432f6e2e80543bb1d565b49403180c520eef66a5
> Bug: https://github.com/dart-lang/language/issues/1274
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175008
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,scheglov@google.com,johnniwinther@google.com

Change-Id: I70b4adaf13f412a42a8128b9c7b9583b4171158e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/language/issues/1274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175321
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-07 21:32:50 +00:00
Lasse R.H. Nielsen 6e29700e16 Update List constructor documentation, deprecate constructor.
Emphasize that the operation is going away,
and mark constructor as deprecated.

TEST= Refactoring+deprecation only, covered by existing tests.

Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-12-07 16:20:28 +00:00
Paul Berry fd2a6c6815 Flow analysis: Track expression variables separately from promotion info.
Previously, we used a single class hierarchy, ExpressionInfo, to store
all the information that flow analysis needs to know about a variable,
including:

1. What is known about the program state if the expression evaluates
   to true/false

2. Whether the expression is a `null` literal

3. Whether the expression is a reference to a variable.

However, in order to address
https://github.com/dart-lang/language/issues/1274 (Infer
non-nullability from local boolean variables), we'll need #3 to be
tracked orthogonally from #1, so that when a local boolean is referred
to later, we can track information of type #1 and #3 simultaneously.

However, it makes sense to keep #1 and #2 in the same data structure,
because future work is planned to represent them in a more uniform
way, as part of addressing
https://github.com/dart-lang/language/issues/1224 (Using `if (foo?.bar
== somethingNotNull)` should promote `foo`).

Change-Id: I432f6e2e80543bb1d565b49403180c520eef66a5
Bug: https://github.com/dart-lang/language/issues/1274
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175008
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-07 16:09:57 +00:00
Johnni Winther c7519a3f01 [cfe] Pass static target to inferInvocation
This is used to detect calls to identical which need special treatment
for flow analysis.

Change-Id: I5109ccc94cdffd8cd46843adfbe4df6b83b92122
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175240
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-12-07 13:21:57 +00:00
Paul Berry 2448fc70b7 Flow analysis: Unit test parenthesized expressions properly.
Previously, the unit tests for flow analysis re-used the logic from
the _WrappedExpression class, which uses
FlowAnalysis.forwardExpression rather than
FlowAnalysis.parenthesizedExpression.  As a result,
FlowAnalysis.parenthesizedExpression wasn't being unit tested.

Change-Id: I1905808fd3a7788cb15d28c82d773369c061da59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175164
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-05 01:40:32 +00:00
Paul Berry 25c73c0e56 Flow analysis: better unit testing of captured variables.
Previously, we didn't have a unit test to verify that variable
captures in nested contexts are propagated to enclosing contexts.

Change-Id: I579bce6d07f61119f44259f1fbf1da7f0800adde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-12-04 22:39:43 +00:00
Paul Berry 6a097edc48 Flow analysis: allow identical to promote values to non-nullable.
This change causes `identical(x, y)` to be treated similarly to `x ==
y` for flow analysis.  For example:

    int? x = ...;
    if (!identical(x, null)) {
      print(x + 1); // Ok, x is known not to be null.
    }

Fixes https://github.com/dart-lang/language/issues/1226.

Bug: https://github.com/dart-lang/language/issues/1226
Change-Id: If2939d3d4dd0dc9d7aaf39984045e9ec3e10ce7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-04 14:40:15 +00:00
Paul Berry d4f3c02612 Flow analysis: Get rid of initialize and _freshVariableInfo.
The FlowModel._freshVariableInfo field was an optimization with
dubious benefit (it avoided a single allocation when seeing a variable
for the first time).  And it is getting in the way of changes I have
planned for https://github.com/dart-lang/language/issues/1274 (which
will require each fresh variable to be allocated different
information).

Removing FlowModel._freshVariableInfo means that now we have a call to
VariableModel.fresh() whenever we see a variable for the first time,
so we can take advantage of this to elimiate the
VariableModel.initialize() method, and simply allocate the
VariableModel in the initialized state when it's appropriate to do so.

Change-Id: I4b6f7d004fff72eaa4025fdf79e9ca29a81d7f96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174566
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-03 13:10:48 +00:00
Janice Collins 951046f94b Update lower SDK constraint of analyzer packages to 2.9.
2.9 is two stable versions behind current, as discussed in
the analyzer standup.

Change-Id: I403460ff1621ccfa07192ae4dcf3fa89bf45b152
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174861
Auto-Submit: Janice Collins <jcollins@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-12-02 22:48:57 +00:00
Paul Berry 4234769982 Flow analysis: remove joinUnassigned and markNotUnassigned methods.
They were not being used.

Change-Id: I9f82b02e6e06327de9d7da7092e649ab08a5e658
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-02 20:53:58 +00:00
Paul Berry 1779cc86d2 Rework flow analysis unit tests based on a mini-AST representation.
In preparation for some flow anaylsis work I intend to do this month,
I want to make the flow analysis unit tests easier to understand and
maintain.  This CL creates an AST representation that models just
enough of the Dart language to be able to do flow analysis testing, so
that when reading or writing a flow analysis unit test, instead of
having to remember the correct sequence of calls to FlowAnalysis to
model a given construct, you can just create a mini-AST representation
of the given construct and pass it to the flow analysis test harness.

The mini-AST model for expressions contains methods that can be used
to build larger expressions out of smaller ones, so a lot of code can
be modeled compactly.  For example, to create a mini-AST model of the
statement `x = y && z == null;`, call
`x.write(y.read.and(z.read.eq(nullLiteral()))).stmt`.

Change-Id: I11e3882078fdc5797176019398db48011232cf35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174560
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-01 22:41:56 +00:00
Konstantin Shcheglov f6362881d5 Make 'uniqueName' a field in ErrorCode.
It started as a way to speed up IgnoreValidator, becaus computing
uniqueName as a concatenation of 'runtimeType' and 'name' was expensive.
We solved it in a better way, but I think this change is still useful.

Change-Id: I7d3cb8c91f4ca27a0aa3b93f8572cf12c6757bae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174322
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-01 21:41:08 +00:00
Konstantin Shcheglov 295a9a856e Prepare to publish analyzer 0.41.1 and _fe_analyzer_shared 14.0.0.
Change-Id: I3d103aa01f306b9f9ad1118fb56c392cf0cded7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-30 20:14:43 +00:00
Konstantin Shcheglov 6ca2c409dc Add one ErrorCode.temporary2()
We need to add `uniqueName`, migrate a couple of existing subclasses,
and then do a bigger change
https://dart-review.googlesource.com/c/sdk/+/174322

R=brianwilkerson@google.com

Change-Id: If9ad2be70aae6fa7f53e57836438c4bfd8be92dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174325
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-29 07:20:13 +00:00
Johnni Winther 90ec6f2531 [cfe] Ensure that shorting is stopped before expression usage
The creation of the shorting stop expression was done lazily
in NullAwareExpressionInferenceResult.expression. Since the shorting
calls flow analysis to stop null promotion doing this out of order
let to inconsistent flow analysis state.

This CL introduces an `inferNullAwareExpression` the allows to
caller to continue the shorting (if in an opt-in library). The
inferExpression method, used everywhere else, stops any shorting
currently in progress.

Closes #43275

Change-Id: I448163e29bdb0de8e493e5c62aa0474d0c9a593f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173729
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-11-25 11:28:13 +00:00
Johnni Winther d75f7005a0 [cfe] Stop shorting in ??
Closes #44276

Change-Id: I60f398c413f3b40215e9049ee3292eaf7f700d7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173722
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-11-24 16:01:38 +00:00
Konstantin Shcheglov d1cc9b6f27 Prepare to publish analyzer 0.41.0 and _fe_analyzer_shared 13.0.0.
Change-Id: I26118cd7bac02e649e64df7cd0b93c2203e2f954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-14 00:26:54 +00:00
Johnni Winther 15c35c2f88 [cfe] Update message for failure to run sound null safety
Closes #44149

Change-Id: Ifcfd951ec616132332aef15058b45d4a49f250cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171594
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-11-12 14:33:36 +00:00
Jens Johansen 7b75bd8ece [CFE] Special case StrongModeNNBDPackageOptOut message in IncrementalCompiler
This CL fixes the wrong message, so - when in the process of fixing
the package nnbd settings - one gets the correct message, mentioning the
right packages and no longer mentioning the fixed ones.

Change-Id: Ied26094055e56b44dfdd2e942b98eb9e1e7968fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170423
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-05 09:43:23 +00:00
Jens Johansen 60a5c58196 [CFE] Fix not getting rid of NNBD error in package in incremental compiler
This fixes the issue of the error not going away, but can (see added
test) give a wrong error message when in the process of fixing the issues.

A follow-up CL will (try to) correct the wrong error message.

Change-Id: I3547fe5fb5cfd179897996029a00a4995a967e54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170422
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-11-05 08:47:42 +00:00
Jens Johansen 332ce76055 [CFE][kernel] Add 'invalid' nnbd mode; use when trying to out out when compiling in strong mode
Change-Id: I3d1a8da4378cd59e733fc796df38ae98aaf59d6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169881
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-03 14:12:56 +00:00
Paul Berry b8a243ea48 Remove unnecessary bool return types from flow analysis methods.
The `bool` return types were added to `FlowAnalysis` methods
`nullAwareAccess_rightBegin`, `ifNullExpression_rightBegin`,
`equalityOp_end`, and `isExpression_end` in September as part of an
effort to fix mixed-mode unsoundness loopholes by having the front end
throw exceptions if "impossible" conditions arose.  We later decided
that we would prefer to allow these conditions to arise without
generating exceptions, because that makes it easier for the user to
write defensive mixed-mode code.  So the booleans stopped being used.
This CL removes them entirely.

Change-Id: Ia0ff91a22fe79c2df1dea89bbb286c84a3603821
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170125
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-11-03 12:42:26 +00:00
Srujan Gaddam ed009afc4c [package:js] Add static errors for invalid extends
Bug: https://github.com/dart-lang/sdk/issues/37896

dart2js disallows JS interop classes from extending Dart classes,
and ddc does not work as expected. Dart classes that extends JS
interop classes can't be declared in ddc and throw an error on
usage in dart2js. This CL adds static errors for both cases.

Change-Id: I72001d2e8bec046c0e1ab4c06fed8fcf84ade259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164840
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2020-10-28 16:04:15 +00:00
Konstantin Shcheglov 47a2ab2866 Prepare to publish analyzer 0.40.5 and _fe_analyzer_shared 12.0.0.
Change-Id: I58b8b62dd33343896900d398d8066777bb12e768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-27 19:12:27 +00:00
Alexander Markov 1615c04c63 Remove bytecode generator
Change-Id: Ic5fd2ab67c10ae642ee277a5acd9b4084e059861
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167762
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 19:30:43 +00:00
Johnni Winther 389201d6e4 Improve null-safe package dependency error message
Make it even clearer that the null safe package error is not a bug in Dart, but a missing dependency in the user's project. This is intended to reduce user confusion, as in https://github.com/flutter/flutter/issues/68787.

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

GitOrigin-RevId: cb72634b256d27f053f273a339caefcbb05567fc
Change-Id: I188e0aaa2d2b82bbd705029aa71705c7de53f1ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168981
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 17:19:42 +00:00
Jens Johansen c36d4d65af [parser] Give errors when 'external' comes in wrong order
Fixes https://github.com/dart-lang/sdk/issues/43851
Fixes https://github.com/dart-lang/sdk/issues/43858
Fixes https://github.com/dart-lang/sdk/issues/43859

Change-Id: I33c9cde01a0843efba3ca0d0a679f4e31b06237c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168650
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-23 09:19:01 +00:00
Jens Johansen 553230ffb4 [parser] Give errors when 'abstract' comes in wrong order
Fixes https://github.com/dart-lang/sdk/issues/43855
Fixes https://github.com/dart-lang/sdk/issues/43856
Fixes https://github.com/dart-lang/sdk/issues/43857

Change-Id: I83ee716288741d2d84a1993e9743ad4b82af22ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168646
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-23 08:05:31 +00:00
Jens Johansen 5a6129406f [parser] Consistently disallow 'late' without 'var', 'final' or type
Fixes https://github.com/dart-lang/sdk/issues/43811
Fixes https://github.com/dart-lang/sdk/issues/43812
Fixes https://github.com/dart-lang/sdk/issues/43813

Change-Id: I39de527883d33459694ec0f91b769676eb52d54b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168641
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-23 06:28:51 +00:00
Paul Berry 96d3efcf48 Exclude pkg/_fe_analyzer_shared/test/constants/data_2 from analysis.
This directory contains test data that isn't expected to analyze
cleanly.

Change-Id: I130db36badad76655546de7acf8f4382c54433e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-21 19:03:34 +00:00
Johnni Winther fa6399ff81 [cfe] Add messages in preparation for enabling non-nullable by default
The added messages handle the situation in which null safety is enabled
by default but is turned off either by language version or by explicitly
passing --enable-experiment=no-non-nullable

Change-Id: Iec43daf19a80f555e838635c83542fdb243b8ed4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168647
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-21 13:51:03 +00:00
Joshua Litt 043bebcd02 [dart2js] Fixes to dart2js unit tests to support nnbd by default.
Change-Id: I440dddd34a62bfe8c0f3fd563888acb680c2b031
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168141
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-10-20 18:40:44 +00:00
Johnni Winther 137c7b6c84 [cfe] Explicitly run front_end unittest without non-nullable
This prepares front_end unittests for turning on non-nullable by default.

Change-Id: I9588a2d026ab9f5b1dcf08a140d25bd5dca3d5bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168346
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-20 13:13:33 +00:00
Anna Gringauze f04bc85e4f Refined scope calculation in expression compiler
- make sure nested blocks scopes are visited
- make sure variable definitions do not leak beyond block scopes
- properly collect scopes for loops, if statements, constructors
- add calculation of fileEndOffsets for blocks
- save block file offsets to dill
  - update binary format version
  - change kernel readers and writers to read and write block offsets
  - change vm readers to read and block offsets for new version
- add missing fileOffsets and fileEndOffsets on functions for
  late fields
- add missing fileOffsets and fileEndOffsets on functions for
  extensions
- add errors on failures to find scope
- find libraries for private fields correctly
- add more expression compilation tests
- add test to verify fileOffsets and fileEndOffsets are set for
  SDK summary (will add full dill tests later)

Closes: https://github.com/dart-lang/sdk/issues/40278
Related: https://github.com/dart-lang/sdk/issues/34942

Change-Id: I5bc1bb645543045b689d8d61069ee77dc4ee9025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167541
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-20 01:44:52 +00:00
Johnni Winther 16f7ce8e57 [cfe] Warn on null aware access on this and static members
Closes #43703
Closes #43461

Change-Id: I861462b5fcf31d5459c17cbe1604ce285c359dec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167563
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-15 08:48:33 +00:00
Joshua Litt cbbd76ef2c [dart2js] Port deferred_loading_test to features.
Change-Id: I683f82fe1096963392f78f9dd3b640b66765b8b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166604
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-10-09 21:10:17 +00:00
Paul Berry 7a1e92a670 Ensure that assert statements promote properly in unreachable code.
Fixes #40009.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I96561a72b6ba8dd8b8b95a4d9827d195941ea038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 18644c338b Ensure that while statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I492b465b08a0f00549e8e69390cead35af211e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry f51fb064cc Ensure that try/catch statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ie4b8809c6f37ff67891bc874c0c0ec10c70eb9fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry ef1646697c Ensure that switch statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I00a8fcf52bce131874ba6d96680b11e8bc1a549c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 2601fa6d78 Ensure that && and || expressions promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ib06449624de9320f5229957511ebaaee92c75ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166606
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 17ebbfcbda Ensure that labeled statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ice9b50ee6a7e9ffc32635312dc951362ff0da665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry ce7accb828 Ensure that ?? and ?. expressions promote properly in unreachable code.
Due to https://github.com/dart-lang/sdk/issues/43725 these have to be
updated in a single atomic CL.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ifbd5fdee6379b7cbee5ab135f72a013134b70aa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 51c6ba0edb Introduce distinct subclasses for _SimpleContext.
Note that due to https://github.com/dart-lang/sdk/issues/43725 we
can't yet downcast to these subclasses in all cases; added a test case
that would fail if we did.

Change-Id: Idd498840484a6a4c60a0cf2f8e01092ba75e7d2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-08 17:15:55 +00:00
Johnni Winther 5a2a435b6e [cfe] Use combined member signature for override inference.
Closes #43381

Change-Id: Id3ba97d717556f807eac1115e1c3570662cab87c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166240
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-08 15:29:05 +00:00
Paul Berry c13f4ab08b Adjust flow analysis of for each statements for consistency with for.
The recent changes to `for` statements were necessary to ensure that
if a `for` statement causes type promotion due to an unreachable
branch without type promotion joining a reachable one with type
promotion, the type promotion would still happen properly even if the
top of the `for` statement was itself unreachable.  There is no need
for a similar change to `for each` statements, because they are simple
enough that this situation cannot arise.  But it's still worth making
the corresponding change for consistency.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Idabf7745f04a99152e688bf050a8d80e07b004e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166520
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 20:01:34 +00:00