Before, the part-URI was serialized as a file-URI and conflated with
source location information. The part-URI is the URI in the following
declaration in a Dart source file:
part "URI";
This is different from what we normally call a file-URI. A file URI
is used to point to the source location of the part declaration, not
the URI in the part declaration.
Furthermore, the field was serialized using writeUriReference which
only works for URIs that are in the uriToSource map on a Component.
Although this might seem like a safe optimization, it doesn't work
if the uriToSource map is omitted or if a part declaration refers to
a missing file.
Finally, due to the confusing use of fileUri, LibraryPart was
mistakenly implementing FileUriNode and annotations were stripped
of source locations if the source for the part were omitted from
uriToSource.
The partUri field is now an unresolved string that can be resolved
against either the parent library's import- or file-URI to obtain
either version as needed.
Change-Id: I255cb4eeaf89928292ab32a2f6be9ead6cc8cee1
Reviewed-on: https://dart-review.googlesource.com/49500
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
In addition to improving recovery when an enum declaration is missing
a body, this CL also fixes ensureBlock to report an error on the
correct token and cleans up some more analyzer tests.
Change-Id: I96e9f8380b8d92082d94fcc9fa4b8cfe113fa238
Reviewed-on: https://dart-review.googlesource.com/48980
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This CL changes the way linker type inference works. Instead of
walking the operations in an UnlinkedExpr in order and inferring types
directly, it first builds an AST for the expression using ExprBuilder,
then uses ResolverVisitor to resolve the AST and perform type
inference.
This helps ensure that summary type inference and ordinary AST-based
type inference produce the same result, since they now use the same
core algorithm. In particular, this means that summary type inference
now does downwards inference properly.
Since the ResolverVisitor makes greater use of the element model than
the rest of the linker, this required implementing additional methods
in the linker's element model.
This CL includes some minor fixes to ExprBuilder that were uncovered
during testing. It also contains some minor changes to
ResolverVisitor to make it work during linking.
Fixes#32525.
Fixes#32394.
Change-Id: I5ec9b2bf5565ad30b8cc856475334323dc118da8
Reviewed-on: https://dart-review.googlesource.com/48741
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This CL refactors the bodies of the following methods so that they can
be re-used by the summary linker:
- CompilationUnitElementImpl.getType
- LibraryElementImpl.createLoadLibraryFunction
- LibraryElementImpl.getImportsWithPrefix
- LibraryElementImpl.getType
Change-Id: I9b398d87323eb9ec6deb9a9a76bd6e9a1aa6bb76
Reviewed-on: https://dart-review.googlesource.com/48740
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This CL makes the following improvements:
- Makes ParameterElementImpl._unlinkedParam public so that it can be
used by the ExprBuilder.
- Adds logic to ExprBuilder to create elements for closure parameters
and to resolve references to those elements.
- Adds support for async closures.
- Adds support for nested closures.
Change-Id: I4b2c2271dac44bb54eb12049de7143b14adef84a
Reviewed-on: https://dart-review.googlesource.com/48680
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
See #32525.
This CL makes the following changes:
- Extracts the logic from AbstractClassElementImpl.getSetter to a
static method so it can be re-used by the summary linker.
- Modifies ParameterElementImpl._resynthesizeTypeAndParameters so that
it avoids unnecessary calls to resolveLinkedType. This is crucial
because resolveLinkedType is not available when linking.
- Makes it possible to suppress reporting of const evaluation errors
when doing resolution. This is necessary because in order to report
these errors we must do constant evaluation, which is not possible
during summary linking.
- Modifies ResolverVisitor._hasSerializedConstantInitializer to avoid
unnecessary calls to LibraryElementImpl.hasResolutionCapability.
This is crucial because the linker contains an implementation of
LibraryElementImpl that's incompatible with
LibraryElementImpl.hasResolutionCapability.
Change-Id: Iec91bd8d6a68193e091c2438bafcd7cb15488d89
Reviewed-on: https://dart-review.googlesource.com/48681
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This CL is the first in a multi-part effort to remove the `previous`
field from the Token class. This first step introduces a new findPrevious
utility method that finds the the token before a given token in a token stream,
and then replaces usages of token.previous with calls to this
new findPrevious utility.
Change-Id: I57de4e542adb5950f1bddd951ff555dd98b19b3b
Reviewed-on: https://dart-review.googlesource.com/48461
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This CL moves _ConstExprBuilder to its own file, renames it to
ExprBuilder (so that it can be re-used for non-const expressions), and
begins adding support for expression types that can appear in
non-const expressions.
It also introduces an expr_builder_test.dart file to make testing of
ExprBuilder easier.
See #32674.
Change-Id: I5a3d91408c51770ee8f70621032a2f0767eaea55
Reviewed-on: https://dart-review.googlesource.com/48462
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This CL makes the following changes:
- Extracts the implementation of ClassElementImpl.getNamedConstructor
to a static method so that it can be re-used by
ClassElementForLink_Class.
- Adds a UnitResynthesizerMixin class so that unit resynthesis methods
can be shared between the resynthesizer and the linker.
Change-Id: I694d6fef511b5bb734ea78095834d6c68e22bf63
Reviewed-on: https://dart-review.googlesource.com/48380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
An expando is a better conceptual fit, since we are using
typesWithImplicitTypeArguments as a substitute for adding a new
property to every DartType object. Using an expando rather than an
identity set also has the advantage of interacting better with the
garbage collector, since the expando only has weak references to its
keys.
Change-Id: I39f538bd40b5ef264d637dbc8fafc11194ae27fa
Reviewed-on: https://dart-review.googlesource.com/48321
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
I intend to re-use StaticTypeAnalyzer for performing type inference
during summary linking as part of fixing #32525. Allowing type
propagation to be disabled will allow the linker to do less work, and
avoid the need to implement the type-propagation-related element
methods in the linker's reduced element model.
There should be no functional change with this CL, since
StaticTypeAnalyzer is not used in linking yet.
Change-Id: I5f644e9869ab89dee21b03a3a54bf809926142f5
Reviewed-on: https://dart-review.googlesource.com/48082
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
I intend to fix#32525 by re-using resolver code to perform type
inference during summary linking. This will require the linker's
stripped down element model to be filled out more completely. To
avoid code duplication, I need to first refactor some of the existing
element logic so that it can be re-used by linker code.
This CL makes the following changes:
- LibraryElementImpl._unlinkedDefiningUnit is made non-private so that
the linker will be able to implement it.
- The logic for building a set of import elements from a summary is
moved to a reusable static method.
- The logic for building a set of prefix elements from import elements
is moved to a reusable static method.
- In resynthesize.dart, abstract base classes are created for
_LibraryResynthesizer, _ReferenceInfo, and _UnitResynthesizer.
- Also in resynthesize.dart, mixins are created to allow re-use of
some of the implementation logic in _LibraryResynthesizerContext and
_LibraryResynthesizer.
Change-Id: I34cde04f4aac291e216004e861d6ac354d551c1c
Reviewed-on: https://dart-review.googlesource.com/48081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>