Peter von der Ahé
f559a6d1e9
Throw NSM on unresolved factory redirection.
...
R=paulberry@google.com
Review-Url: https://codereview.chromium.org/2933733002 .
2017-06-13 09:12:20 +02:00
Paul Berry
24bb748bc7
Implement type inference for "not" expressions.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2935763004 .
2017-06-12 17:44:25 -07:00
Paul Berry
d4a64e52e7
Add type inference for assignments to this[...]
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2938443003 .
2017-06-12 14:00:59 -07:00
Paul Berry
5d58191948
Add type inference for assignments to super[...]
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2935783003 .
2017-06-12 13:34:38 -07:00
Paul Berry
cdb1e858d2
Add type inference for assignments to properties.
...
This covers explicit property accesses (using both `.` and `?.`) as
well as implicit properties of `this`.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2931363003 .
2017-06-12 11:33:06 -07:00
Peter von der Ahé
043c0096ad
Complain about use before declaration.
...
R=johnniwinther@google.com
Review-Url: https://codereview.chromium.org/2924423003 .
2017-06-10 10:12:18 +02:00
Paul Berry
6b65fc22f7
Annotate targets of implicit this property gets/sets in inference tests.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2933663002 .
2017-06-09 17:41:13 -07:00
Paul Berry
8f5bcddc31
Implement type inference for assignments to a static variable.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2933643002 .
2017-06-09 17:36:20 -07:00
Paul Berry
ef94f715a9
Add type inference for assignment to local variables.
...
Also fix some upwards inference cases for assignment to index
expressions.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2928033005 .
2017-06-09 15:13:14 -07:00
Paul Berry
4abff2291b
Rework type inference of assignments to index expressions.
...
The approach from the las CL (try to figure out the structure of the
assignment expression from the desugared result) turned out to be
unsustainably complex. In this version we keep track of the structure
while doing the desugaring, and then store the result in a wrapper
object the kernel AST. The wrapper object defers visit methods to the
object it wraps, so when the kernel objects are serialized to disk,
the wrapper disappears.
I also took the liberty of removing the code that inserts types
into the temporary variables and conditional expressions
introduced by desugaring. I will add this in a later CL if it
proves to be necessary.
R=ahe@google.com , scheglov@google.com
Review-Url: https://codereview.chromium.org/2927013004 .
2017-06-09 10:48:07 -07:00
Paul Berry
029771d746
Add type inference for complex assignments whose LHS is an index expression.
...
In later CLs I will expand on this code to handle other kinds of
complex assignments.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2926763003 .
2017-06-08 09:25:24 -07:00
Paul Berry
5c3dd4b11b
Change MethodInvocation.interfaceTarget from a Procedure to a Member.
...
It's possible for the interface target to be a field, e.g.:
typedef void F();
class C {
F f;
}
void g(C c) {
c.f(); // Interface target is C::f
}
Also, this CL fixes MethodInvocation.getStaticType() in the case where
the interface target is a getter.
R=dmitryas@google.com , kmillikin@google.com , scheglov@google.com
Review-Url: https://codereview.chromium.org/2923653003 .
2017-06-07 09:20:53 -07:00
Peter von der Ahé
d6a766bb14
Improve NSM handling.
...
R=paulberry@google.com
Review-Url: https://codereview.chromium.org/2927613002 .
2017-06-07 09:28:13 +02:00
Paul Berry
b18c325f68
Add int.toString() to analyzer mock SDK.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2922383003 .
2017-06-06 13:35:36 -07:00
Paul Berry
49110ba0d6
Fix implementation of fold() in analyzer's mock SDK.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2924853003 .
2017-06-06 13:23:45 -07:00
Paul Berry
7ab22d7ad2
Properly flatten FutureOr types when inferring the type of an async method.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2923733004 .
2017-06-06 13:13:08 -07:00
Paul Berry
f7f9d1766f
Fix corner cases of type inference with implicit references to .call.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2928613003 .
2017-06-06 13:00:26 -07:00
Paul Berry
32e78868bd
Record method invocation targets that are not procedures.
...
We don't yet store the targets in the kernel representation, since
kernel currently requires method invocation targets to be procedures
(see https://codereview.chromium.org/2923653003/ ). But we record the
target that we *would* store in the kernel to instrumentation so that
we can pass tests.
R=ahe@google.com
Review-Url: https://codereview.chromium.org/2920223008 .
2017-06-06 12:27:34 -07:00
Paul Berry
47d50e51a3
Add type inference for this expressions.
...
R=ahe@google.com , scheglov@google.com
Review-Url: https://codereview.chromium.org/2925603002 .
2017-06-06 09:54:19 -07:00
Paul Berry
b5883633f7
Do not annotate type parameters of instantiated function types.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2925693002 .
2017-06-05 13:26:12 -07:00
Paul Berry
2513c2b93f
Adjust expectations for parameterized closures to match front_end behavior.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2925583003 .
2017-06-05 12:51:37 -07:00
Paul Berry
2162b2da9b
Improve annotation of type variables in type inference tests.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2918373003 .
2017-06-05 11:47:07 -07:00
Paul Berry
416a860de5
Mark some more type inference tests as passing.
...
These tests were already working--they just needed expectations files
(and in one case, a `main` method).
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2926433002 .
2017-06-05 10:07:27 -07:00
Paul Berry
eefdf15aa1
Perform type inference on default values of optional/named parameters.
...
R=ahe@google.com
Review-Url: https://codereview.chromium.org/2915763008 .
2017-06-01 21:18:37 -07:00
Paul Berry
da869cff4e
Fix inference test annotation of named/optional parameters in function types.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2915913004 .
2017-06-01 20:51:29 -07:00
Paul Berry
d17f3f3bbd
Annotate optional parameter inferred types in front end test cases.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2921533004 .
2017-06-01 20:45:51 -07:00
Paul Berry
349f95f687
Fix a corner case of block closure inference.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2914983003 .
2017-06-01 16:07:59 -07:00
Peter von der Ahé
984b13052d
Compute correct return type for factory methods.
...
R=johnniwinther@google.com
Review-Url: https://codereview.chromium.org/2917853002 .
2017-06-01 14:02:05 +02:00
Peter von der Ahé
679cd68453
Update expectations files.
...
R=johnniwinther@google.com
Review-Url: https://codereview.chromium.org/2921623002 .
2017-06-01 14:01:12 +02:00
Paul Berry
7cdf85da06
Fix a corner case of function type inference.
...
When an expression function's expression has type `dynamic` (or
`Null`, since `Null` is coerced to `dynamic`), the inferred return
type is taken from the context.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2921583002 .
2017-05-31 21:26:14 -07:00
Paul Berry
a122a6409e
Add some top level type inference rules for property gets.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2914113002 .
2017-05-31 15:17:16 -07:00
Paul Berry
cd5bacbc54
Implement type inference for PropertySet.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2919623002 .
2017-05-31 15:09:28 -07:00
Paul Berry
f9c1cab33b
Remove some bogus type promotion code.
...
This code was part of an attempt to prototype some possible extensions
to type promotion to handle `if (x is! Foo)`. I thought I had
rendered it harmless, but it was having some buggy effects.
Also added a test case demonstrating the problem.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2914093002 .
2017-05-31 13:40:33 -07:00
Paul Berry
26c61e4d22
Implement type inference for PropertyGet.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2921443002 .
2017-05-31 12:26:10 -07:00
Paul Berry
54c57f0015
Remove TODOs from KernelConditionalExpression._inferExpression.
...
The code is correct as is (at least insofar as it matches analyzer's
behavior). I've added a new test to verify this, and I've made a
comment on the spec asking for it to be updated to match analyzer's
behavior.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2916633002 .
2017-05-31 10:04:20 -07:00
Peter von der Ahé
cdfd07b9d3
Don't read platform files during testing, and avoid trimming broken programs.
...
R=johnniwinther@google.com
Review-Url: https://codereview.chromium.org/2912353002 .
2017-05-31 15:03:30 +02:00
Paul Berry
b89e8cd1a1
Fix inferInvocation for top level inference.
...
When inferring the type of an invocation for top level inference, if
type parameters are not specified, then it is an error. So we should
not recurse into subexpressions (even if inferenceNeeded is `true`).
This avoids confusion by making it clear to the user that we don't
take subexpressions into account when doing top level type inference,
even when recovering from type inference errors.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2911323002 .
2017-05-30 14:43:06 -07:00
Paul Berry
6a809aa432
Add type inference logic for "for-in" loops.
...
R=ahe@google.com
Review-Url: https://codereview.chromium.org/2908973002 .
2017-05-29 07:35:46 -07:00
Paul Berry
e4042e5de2
Implement type inference for await expressions in front_end.
...
This required implementing FutureOr rules in
type_constraint_gatherer.dart. It also required fixing an incorrect
type in analyzer's mock SDK, which had some follow on effects on
analyzer unit tests.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2904263003 .
2017-05-27 07:30:46 -07:00
Paul Berry
5d69e056d3
Add type inference support for "call" invocations of function expressions.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2911683003 .
2017-05-26 13:34:42 -07:00
Paul Berry
d859cc6e4e
Add type inference logic for map literals
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2905353002 .
2017-05-26 13:09:53 -07:00
Paul Berry
3c730528fc
Treat type inference context dynamic as equivalent to an empty context.
...
This replicates analyzer behavior.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2903153006 .
2017-05-26 11:26:35 -07:00
Paul Berry
f60bad7fbc
Fix type inference of redirecting factory constructor invocations.
...
Their types should be inferred based on the initial target of the
invocation, not the redirected target.
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2904133002 .
2017-05-25 17:19:20 -07:00
Paul Berry
ee6fd5e1a3
Perform type inference on redirecting initializers (C() : this(...);).
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2905163002 .
2017-05-25 14:47:53 -07:00
Paul Berry
069e1bda1c
Correctly infer the return context while compiling a factory constructor.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2907643003 .
2017-05-25 14:17:59 -07:00
Paul Berry
cefc4cc768
Perform type inference on explicitly typed fields.
...
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2905123002 .
2017-05-25 13:22:26 -07:00
Paul Berry
1e45167514
Update strong mode expectations to reflect kernel type parameter conventions.
...
When outputting the name of a type parameter, Kernel follows two
special conventions:
- It fully qualifies the name of the type parameter with respect to
the scope of its declaration; so for example a type parameter `T` of
a class `C` in a library `lib` might be annotated as `lib::C::T`.
- Within a factory constructor, type parameters of the class are
annotated as though they are type parameters of the factory
constructor (this is because factory constructors are represented in
kernel as static methods).
This CL adjusts the strong mode type inference tests to reflect this
behavior (and modifies analyzer's front_end_inference_test so that
follows the kernel conventions).
R=scheglov@google.com
Review-Url: https://codereview.chromium.org/2909503004 .
2017-05-25 11:11:14 -07:00
Paul Berry
560cf61b3b
Add type inference logic for cascade expressions.
...
R=ahe@google.com , scheglov@google.com
Review-Url: https://codereview.chromium.org/2903243002 .
2017-05-25 09:30:26 -07:00
Paul Berry
8a92a2a79c
Infer the types of initializing formals from the corresponding fields.
...
This inference is enabled for both strong and non-strong mode, since
it is mandated by the Dart 1.0 spec.
R=ahe@google.com , scheglov@google.com
Review-Url: https://codereview.chromium.org/2908453002 .
2017-05-25 04:47:44 -07:00
Paul Berry
6b100c007b
Use declared return type for inference of return and yield statements.
...
R=ahe@google.com
Review-Url: https://codereview.chromium.org/2899073004 .
2017-05-24 09:28:26 -07:00