Commit Graph

517 Commits

Author SHA1 Message Date
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
Paul Berry 54bd8a79c4 Fix top level type inference in the event that there are circularities.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2900193002 .
2017-05-23 14:01:46 -07:00
Paul Berry b16b0e8edb Fix type inference of yield* statements
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2898313002 .
2017-05-23 13:10:40 -07:00
Paul Berry 79b4382784 Fix type inference of assignments to local variables.
If the variable's type was inferred, the inferred type should be used
as the inference context for the RHS expression.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2900873002 .
2017-05-22 12:54:29 -07:00
Paul Berry 37db02a355 Add some type inference for "yield" statements.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2899833002 .
2017-05-22 11:38:20 -07:00
Paul Berry 4b9485db73 Fix type inference of factory constructor invocations.
Factory constructors are represented as static methods with dynamic
return type; in order to type infer them properly we must use the type
of the enclosing class as the return type (with type parameters
substituted appropriately).

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2900553003 .
2017-05-22 11:18:33 -07:00
Peter von der Ahé 8f17ae7709 Update status and expectations.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2900753002 .
2017-05-22 15:22:38 +02:00
Paul Berry bf15116d0f Handle FutureOr type when inferring async closures.
R=asgerf@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2892593005 .
2017-05-20 20:16:59 -07:00
Paul Berry 4e3f10669d Flatten futures when inferring the type of an async function expression.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2895063003 .
2017-05-20 20:00:18 -07:00
Paul Berry 8c04f1a7f9 Revert "Flatten futures when inferring the type of an async function expression."
This reverts commit a0d98fe474.

This should address failures in the buildbot "vm-kernel-linux-release-x64-be".

TBR=scheglov@google.com

Review-Url: https://codereview.chromium.org/2893813002 .
2017-05-17 20:24:37 -07:00
Paul Berry a0d98fe474 Flatten futures when inferring the type of an async function expression.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2890083002 .
2017-05-17 14:56:03 -07:00
Paul Berry 28ed82075e Fix a type inference corner case: return expression where void expected.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2888073003 .
2017-05-17 10:01:18 -07:00
Paul Berry 830be5727d Minor type inference fixes to do with null and bottom types.
This CL makes the following fixes:

- Updates analyzer's front_end_inference_test to represent the bottom
  type as "<BottomType>" (consistent with Kernel).

- Implements type inference of "throw" expressions.

- Does not coerce bottom to dynamic when inferring the return type of
  a closure.

- Does not coerce Null to dynamic when inferring the return type of a
  block closure.

- Ignores bare "return;" statements when inferring the return type of
  a block closure.

- Infers Null when a block closure lacks "return <expression>;"
  statements.

- Implements correct rules for LUB(Null, x), by treating Null as
  bottom.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2886873005 .
2017-05-17 05:36:11 -07:00
Paul Berry 72d3fbc85f Implement type inference of static invocations.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2885963002 .
2017-05-16 18:33:24 -07:00
Paul Berry 6a48f79ba3 Disable type erasure during strong mode tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2883343002 .
2017-05-16 09:47:21 -07:00
Paul Berry 51eb5cef42 Minor type inference fixes.
- Add num::== and Iterable::where to analyzer mock SDK.

- Do not default parameter types to dynamic in BodyBuilder or
  KernelFormalParameterBuilder.  This is now handled by the
  KernelVariableDeclaration constructor.

- Only infer function expression parameter types in strong mode.

- Record inferred function expression parameter types to
  instrumentation.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2886443003 .
2017-05-16 08:42:25 -07:00
Paul Berry c519414702 Add subtype matching rules for function types.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2883133002 .
2017-05-15 14:04:32 -07:00
Paul Berry 358c3da935 Make type inference handle overloaded arithmetic operations.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2883083002 .
2017-05-15 11:43:50 -07:00
Paul Berry a4bdc5cb4e Make another type inference test pass.
Type inference for this test was already working; it just needed an
expectation file and a main function.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2882953003 .
2017-05-15 10:00:49 -07:00
Paul Berry bd15c223de Implement function-typed formal parameters in OutlineBuilder.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2884483002 .
2017-05-15 06:28:51 -07:00
Konstantin Shcheglov dd62ad5d77 Store Typedef(s) in kernel when parsing with Fasta, deserilize in DillLibraryBuilder.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2882893002 .
2017-05-14 17:51:55 -07:00
Paul Berry 66a8d2ec9c Implement full closure inference logic.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2882863002 .
2017-05-14 15:21:32 -07:00
Paul Berry 28e742a31c Infer return types of closures (basic support).
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2878173002 .
2017-05-13 06:13:31 -07:00
Paul Berry 6dc30771b3 Don't type promote local functions.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2877253003 .
2017-05-12 18:58:52 -07:00
Paul Berry cb8ffd9693 Remove List.map from analyzer's mock SDK
In the true SDK, List does not override map()--it inherits the
implementation from Iterable.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2884443002 .
2017-05-12 12:02:02 -07:00
Paul Berry fe991b20dd Update expectations files to get more strong mode inference tests to pass.
The logic to make these tests pass was already in place, but their
expectations files either didn't exist or needed tweaking.

R=scheglov@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2883533002 .
2017-05-12 11:20:20 -07:00
Paul Berry 99d9a77be8 Get rid of promotedType=none annotations
These turned out to be really unweildy.  Besides, they aren't
necessary since the test framework will flag a failure if a type gets
promoted when it is not expected to be.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2865403007 .
2017-05-11 11:14:23 -07:00
Paul Berry 0c64db009a Exclude function name from function type annotations in front end type inference tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2875103002 .
2017-05-11 10:17:55 -07:00
Paul Berry 17c23be470 Set MethodInvocation.interfaceTarget during type inference.
We need to compute the interface target in order to do the inference
anyway, so this is a reasonable time to store it.

Also annotate the inference tests with interface targets so that we
can verify that the interface targets computed by analyzer match those
computed by Fasta.  Note that this causes a few strong mode tests to
fail that were previously passing, due to the fact that type inference
in Fasta is incomplete.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2874033003 .
2017-05-10 14:31:05 -07:00
Paul Berry 6208c8f05c Propagate type inference through variable gets.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2872323003 .
2017-05-10 12:21:32 -07:00
Paul Berry e68668f88d Fix method call type inference with explicit type parameters.
This was broken for three reasons:

- We weren't recording the fact that the type parameters were
  explicitly provided, so the inference code path to handle this case
  wasn't being exercised.

- The inference code path to handle this case was accidentally
  referring to the `inferredTypes` variable, which is `null` in this
  case.

- We were not checking for the case where the user provided the wrong
  number of type parameters.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2874053002 .
2017-05-10 11:00:29 -07:00
Paul Berry 22f68e6450 Fix annotation of generic method invocations in Fasta inference tests (again).
In c8026439dc, I was overzealous and
annotated all generic method invocation parameters, whether they were
inferred or explicit.  We just want to annotate the inferred ones.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2866363004 .
2017-05-10 10:21:44 -07:00
Paul Berry 6e499b16cf Implement type inference of method invocations in Fasta.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2873813002 .
2017-05-09 16:51:05 -07:00
Paul Berry c8026439dc Fix annotation of generic method invocations in Fasta inference tests.
Note that one Fasta test starts failing as a result of this change,
due to the fact that the Fasta type inference logic is not yet
complete.

R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2867253004 .
2017-05-09 15:25:20 -07:00
Paul Berry 12ee9643d9 Fix annotation of promoted parameters in Fasta inference tests.
Previously, we only annotated "promotedType" for local variables; we
need to annotate it for function parameters as well.

Note that a few Fasta tests start failing as a result of this change,
due to the fact that the Fasta type promotion/inference logic is not
yet complete.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2868133002 .
2017-05-09 13:59:21 -07:00
Paul Berry ea6b301e81 Get some more strong mode type inference tests to pass
The functionality necessary to get these tests to pass is actually
already present; they just needed expectations files, and in one case,
a main() method.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2872903003 .
2017-05-09 08:36:30 -07:00
Paul Berry 4eee6cb5ea Fix constructor invocation type inference.
Three problems are fixed:

- I forgot to pass the `downwards` flag when doing downwards inference.

- I forgot to initialize the `formalTypes` and `actualTypes` arrays.

- I wasn't tracking whether constructor type arguments were implicit
  or explicit, so constructor type inference wasn't actually
  happening.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2864853002 .
2017-05-08 14:41:56 -07:00
Paul Berry fcd22c2c89 Update expectations for instance creations to match front_end.
Front_end wants to annotate instance creations like this:

    new /*@typeArgs=Foo*/ bar();

Whereas the existing tests use this style:

    /*@typeArgs=Foo*/ new bar();

It's easier to modify the analyzer code to use the front_end style
than to update the front_end to use the analyzer style, and besides, I
think the front_end style makes more sense.

I've also added a boolean to front_end_inference_test.dart to allow
expectations to be updated more easily in the future.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2867113002 .
2017-05-08 11:02:35 -07:00
Paul Berry 893a08c8dc Implement type inference of constructor invocations in Fasta.
Fixes 68 inference tests.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2865623003 .
2017-05-05 11:58:56 -07:00
Paul Berry 350e93b1a8 Fix handling of null/bottom in front_end type inference.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2863603004 .
2017-05-05 07:02:17 -07:00
Paul Berry de32b9a32a Hook up full list literal type inference logic.
AFAIK this is the full algorithm for list literal inference.  But some
list literal tests still don't pass.  I will investigate and fix in
future CLs.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2863733003 .
2017-05-05 04:23:39 -07:00
Konstantin Shcheglov a3db98c5de Infer VariableSet types.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2855323004 .
2017-05-04 13:37:02 -07:00