As of commit 67b99e4b33, it is now
consistently a compile error for a prefix not to be followed by '.'.
(Previously, there were two exceptions in which a prefix not followed
by '.' was treated as though it was preceded by "this.")
This CL updates analyzer to be consistent with the new spec langauge,
and modifies the tests in tests/language accordingly.
Dart2js and the VM do not yet produce the correct compile-time error
in all circumstances. See issues #23611 and #23612.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1186033004.
Previously, the least upper bound code was only half-written--it
computed correct results if both types were interface types, and
otherwise returned null. Now we always return a non-null type.
Unfortunately, the full least upper bound algorithm in the spec
requires referencing types not reachable from the types being
compared; thus in order to execute it we need access to the
TypeProvider. We can't do this with the existing API. So that API
has been deprecated. The new API uses a class TypeSystem which
contains a pointer to the TypeProvider. This new class should also be
a useful starting point in case we need to make the type system more
pluggable in the future.
Clients that use the old API will see no change in behavior--they will
still get the half-written algorithm.
Still to be addressed in future CL's:
- Deprecate getSmartLeastUpperBound.
- Fix calls to getLeastUpperBound and getSmartLeastUpperBound in analysis
server.
- Implement least upper bound computation for function types.
- Make sure type parameters function correctly in the presence of F-bounded
polymorphism.
- Implement shared tests.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1179343004.
Add RESOLVED_UNIT_NO_CONSTANTS as a public result.
Document results that are computed with the task model.
We need this to be able to use onResultComputed() in Analysis Server and
know that we will get enough information.
R=brianwilkerson@google.com
BUG=
Review URL: https://codereview.chromium.org//1181603004.
This CL makes analyzer consistent with the VM and the spec, by
producing a compile-time error for code such as:
class C {
final x = 1;
const C() : x = 2;
}
main() {
const C();
}
Note that Dart2js also produces an error in this circumstance, but its
error is too general (the error should only be produced if the const
constructor is invoked using "const"; if the const constructor is
invoked using "new", or is not invoked at all, it should only be a
warning). See #23618.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1175073002.
It is a compile-time error for a constant value to depend on a
non-constant value (or a non-constant constructor), however the
analyzer still needs to be able to handle it.
This CL adjusts the ConstantEvaluationEngine so that it consistently
reports all the dependencies of a given constant (whether those
dependencies are constant are not), but which is tolerant of being
asked to compute a constant value of a non-constant.
Fixes test failures with the new task model enabled. No behavioral
change with the new task model disabled.
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1167413005.
If 'p' is an import prefix, then 'p = ...' is treated as synonymous
with 'this.p = ...', and 'p()' is treated as synonymous with
'this.p()'. In all other circumstances where 'p' is not followed by
'.', the spec calls for a compile time error.
Previous to this CL, 'p' not followed by '.' was being treated as
synonymous with 'this.p' under all circumstances. This CL brings
analyzer in line with the spec, and updates the tests in
tests/language accordingly.
The VM and Dart2js currently fail to implement the compile-time error
properly. See issues #23611 and #23612.
Fixes issue #23461.
R=scheglov@google.com
Review URL: https://codereview.chromium.org//1173523002.
If a constant constructor does not contain an explicit call to
super(), and the base class lacks an explicit constructor, we need to
avoid marking the implicit base class constructor as a dependency,
since it is non-const. (Note: this shouldn't occur very often in
real-world usage since is a compile-time error, but we still need to
be able to analyze it without throwing an exception).
Fixes the following test when the new task model is switched on:
co19/Language/07_Classes/6_Constructors/3_Constant_Constructors_A03_t02
R=brianwilkerson@google.com
Review URL: https://codereview.chromium.org//1168563004