Previously, we were using the storage space provided by
`InferenceContext.getContext` for two purposes: 1. to store the
inference context passed down from the parent AST node, and 2. to
store the refined inference context computed by
ResolverVisitor._computeContextType. After type inference, the data
that remained was the refined interface context (2); however,
ErrorVerifier._checkForRawTypeErrors was expecting to be able to
retrieve the downward inference context in order to report
`HintCode.STRICT_RAW_TYPE` correctly. This caused a failure in
test_strictRawTypes_emptyMap (in checker_test.dart).
This CL fixes the issue by storing the refined inference context (2)
in a field in `SetOrMapLiteralImpl`, so that it doesn't overwrite the
downward inference context (1).
It also fixes an issue that was previously obscured by this bug, where
we weren't copying over the downward inference context when replacing
a set literal with a map literal. (This fix will become irrelevant
after the next breaking change release of the analyzer, when we stop
creating different objects for set vs. map literals, and simply use
the base class `SetOrMapLiteralImpl`).
In addition, ResolverVisitor._computeContextType has been renamed to
_computeSetOrMapLiteralContextType to clarify that it only computes
context information for set/map literals.
Change-Id: I62a9c4bb6fe755acf60b881948538216af81b515
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96261
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
There are two bug fixes:
- Due to dartbug.com/33441, it's possible that a set/map literal
resynthesized from a summary will have neither its `isSet` or
`isMap` boolean set to `true`. We work around the problem for the
short term assuming such literals are maps.
- The linker method ConstNode.collectDependencies hadn't been updated
to handle the new summary nodes `makeUntypedSetOrMap` and
`makeTypedMap2`.
This CL includes unit tests for these two bug fixes.
Original change description:
> Eliminate uses of old AST node types from pkg/analyzer/lib/src/summary
>
> Change-Id: Ida907040d0461d9ae723421eeac71f4e19a8d4b2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95284
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Bug:
Change-Id: Ie26be4e0e241872ef4c7e183ada1f1d6b5f6e7f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96264
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Some of the "regressions" in CL 94993
(73be247e12) just turned out to be test
expectations that needed to be updated. This CL makes the following
kinds of updates to test expectations:
- Adds info:INFERRED_TYPE_LITERAL when necessary (some of the code for
inferring the types of type literals has been generalized, so this
info is reported more frequently than it previously was).
- Removes duplicate error:*_TYPE_NOT_ASSIGNABLE (it was previously a
bug to report this twice; that bug is now fixed).
Change-Id: I75a6ab3c420c2aa868ec8cb203e33f76a1e57a75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96201
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Also some very basic top-level inference: field formal initializers in
constructors, initializers of top-level variables (for now ignoring
dependencies), setter return type to `void`.
We pass 172 or 590 resynthesis tests, about 29%.
Change-Id: Id70b80ceb7c794627626a1fe94172b0e9ccdda8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95672
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This is one step in refactoring non-nullable enablement
* update AstBuilder to record isNonNullable in CompilationUnitImpl
* update ErrorVerifier to pull non-nullable from CompilationUnitImpl
Change-Id: I78e5f529330f10f294ad1c1b3b7ac8b672a5ee9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95426
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
- ForStatement and ForEachStatement will be replaced by ForStatement2.
- MapLiteral and SetLiteral will be replaced by SetOrMapLiteral.
To ease the transition, the old classes are subtypes of the new
classes, so even though the analyzer still creates instances of the
old classes, clients should be able to start referring to the new
classes in their code. The analyzer will stop creating instances of
MapLiteral and SetLiteral when the experimental flags for the "UI as
code" feature are turned on, and will stop creating instances of all 4
classes when we bump the major version number (which should happen
sometime in March).
For visitors, we've updated the base classes with the following default methods:
visitForStatement(node) => visitForStatement2(node);
visitForEachStatement(node) => visitForStatement2(node);
visitMapLiteral(node) => visitSetOrMapLiteral(node);
visitSetLiteral(node) => visitSetOrMapLiteral(node);
So clients should be able to start revising their visitors to override
the new visit methods rather than the old ones, and the visit methods
in the base classes will automatically forward to the new visit
methods.
Change-Id: Ifde3a2aa3c8c49ce4e65dfaabf086db4dabb73f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95665
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
ba5644b76c fixed an analyzer bug causing
a crash when a top level variable requiring type inference contained a
closure involving type promotion, and removed some explicit types that
were present in the analyzer to work around the bug.
Although the bug has been fixed now, the fix hasn't rolled out in a
release of the SDK. So to avoid people seeing analysis server crashes
when editing the analyzer, I'm re-introducing the workaround.
Change-Id: I5e61345021cd33cb9ad1f017a7619815a38c6a1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95667
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>