The first phase, called `resolve`, happens during top level type
inference; it determines which inherited method a forwarding node
resolves to, and ensures that dependencies are type inferred. The
second phase, called `finalize`, happens at the end of top level type
inference; it creates forwarding stubs if necessary and propagates
covariance annotations.
The reason we need two phases is illustrated by the new test
pkg/front_end/testcases/inference/inheritance_does_not_imply_circularity.dart.
There should be a type inference dependency from I1::x to y, and from
y to C::x. But there shouldn't be a type inference dependency from
C::x to I1::x, since C::x's type is fully specified.
Splitting into two phases makes this work: during type inference, we
can resolve C::x without needing to consult the type of I1::x. Once
type inference is over, and the type of I1::x has been determined, we
can finalize C::x and determine whether any covariance annotations
need to be propagated.
Change-Id: If96e7b23e16723c421f91b3e37fe2a4485919c5c
Reviewed-on: https://dart-review.googlesource.com/13600
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This reverts commit 4bb83e9311
This reverts commit f1b07b2789.
Reason for revert on analyzer bots:
Analyzing pkg/analyzer...
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:625:9 • undefined_identifier
error • Undefined name 'CompileTimeErrorCode' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:625:18 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:626:13 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:635:9 • undefined_identifier
error • Undefined name 'CompileTimeErrorCode' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:635:18 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:636:13 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:645:9 • undefined_identifier
error • Undefined name 'CompileTimeErrorCode' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:645:18 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:646:13 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:655:9 • undefined_identifier
error • Undefined name 'CompileTimeErrorCode' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:655:18 • undefined_identifier
error • Undefined name 'source' at pkg/analyzer/test/generated/compile_time_error_code_kernel_test.dart:656:13 • undefined_identifier
12 errors found.
Change-Id: Ie2035bf40e50c48f85b514c7a3786141cd0f2453
Reviewed-on: https://dart-review.googlesource.com/14061
Reviewed-by: Martin Kustermann <kustermann@google.com>
The outer loops are now through the arguments of the method to be
fixed, and the inner loops are through the inherited methods. This
allows us to handle the situation where a forwarding stub is needed
because isGenericCovariantInterface changes from true to false, but
the forwarding stub doesn't need to be concrete, since
isGenericCovariantImpl is inherited from the base class. (Previously
that situation didn't work because by the time we processed the
inheritance of isGenericCovariantImpl, we had already created a
concrete forwarding stub).
Additional fixes in this CL (necessary to get tests to pass in
meaningful ways):
- Updated InstrumentationValueForForwardingStub to print covariance
annotations on type parameters.
- Updated _createForwardingStub to copy covariance annotations from
the target procedure to the procedure being created.
- Moved call_through_this.dart from runtime_checks/ to
runtime_checks_new/ because the analyzer implementation doesn't
handle this case correctly.
Change-Id: I984a46826a3a4d8ad1a1ce840269498df049fef0
Reviewed-on: https://dart-review.googlesource.com/13963
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
When multiple fixes need to be inserted at the same offset, they need
to be inserted in reverse order, so that they will be in the correct
order in the final file state.
Change-Id: Ifa976c7cb5548869f9f7fcfff2d89ffb2110b882
Reviewed-on: https://dart-review.googlesource.com/13962
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Also remove KernelProcedureBuilder.prepareTopLevelInference, whose
sole purpose was to populate it.
Change-Id: Id42e931ebe6a2b9da4f30e54fc3d33627f84a5b7
Reviewed-on: https://dart-review.googlesource.com/13581
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This addresses the situation where a top level built-in keyword
such as "import" or "export" is used as an identifier
in a top level declaration.
Change-Id: I663ed00502eadd2c639f79e68d26345783911faa
Reviewed-on: https://dart-review.googlesource.com/13361
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Previously, we created genuine kernel objects to represent the
synthetic setters and getters associated with fields. This led to
problems, because a given field would have multiple synthetic setters
and getters associated with it, and those synthetic getters and
setters would fall out of sync with each other during type inference
and covariance propagation.
This CL changes the kernel objects representing synthetic setters and
getters so that they are proxy objects; they inherit most of their
functionality from the corresponding kernel representation, but they
override the properties having to do with types and covariance so that
they refer to the underlying field. This ensures that nothing gets
out of sync, since the field is the single source of truth about its
type and covariance.
Change-Id: Iff44c408e84ef34df337c81e7bfbd125d61020d8
Reviewed-on: https://dart-review.googlesource.com/13281
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
With this CL, we stop creating the old AccessorNode objects and start
creating the inference nodes associated with the new ForwardingNode
infrastructure. This fully integrates top level type inference with
forwarding stub generation.
There is a small difference between the behavior of the old and new
type inference infrastructure: in the old infrastructure, when
inferring the type of a getter or setter, we would consider both
inherited getters and inherited setters. Now, we follow the spec.
This introduces some minor differences from analyzer functionality, so
the tests of this functionality are moved into the "inference_new"
directory.
Change-Id: Ie17df9abf1a3ab99e7d22683ffdf6d1b13ec86be
Reviewed-on: https://dart-review.googlesource.com/13180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This required adding a few extra parser events to allow the type
propagator to update its state when the `?` and `:` are encountered
(similar to what was done for `if`).
Fixes#30620.
Change-Id: I0d3ede8056fd8bab01ead5b242d00803286c9373
Reviewed-on: https://dart-review.googlesource.com/13182
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This will be necessary when we try to integrate type inference with
the creation of forwarding nodes, because getter types can be inferred
from inherited setters and vice versa.
We accomplish this by producing two separate lists (getters and
setters), then merging them together. This results in a list where
correspondingly-named getters and setters are grouped together, with
getters appearing before setters.
Change-Id: I549f0b4354370753a6aa7a15285d778980fb4841
Reviewed-on: https://dart-review.googlesource.com/12900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>