Commit Graph

1972 Commits

Author SHA1 Message Date
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é 4fddc2e4d5 Move code for instantiating Invocation to Target.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2897683002 .
2017-05-22 15:59:06 +02: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
Peter von der Ahé de7edcde74 Fix crash with generalized function types in type tests.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2899693003 .
2017-05-22 14:53:46 +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
Sigmund Cherem 011f8c5873 Reapply CL: first step for modular support in fasta
BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2894283002 .
2017-05-19 19:47:37 -07:00
Sigmund Cherem 54dcc29835 Revert "First step for modular output in fasta."
This reverts commit d9e9382373.

There were bot failures on incremental_kernel_generator test and in
incremental_resolved_ast_test, I'm not sure yet why tests passed locally though.

BUG=

Review-Url: https://codereview.chromium.org/2894273002 .
2017-05-19 15:02:48 -07:00
Sigmund Cherem d9e9382373 First step for modular output in fasta.
Some details:
 - Adds the tree-shaker logic and unit tests for it,

   Note: I'm still not clear on what degree of tree-shaking we can get away
   with. For now I have a mode to delete anything that is not seen explicitly.
   This passes verification for all of our tests so far, but breaks both the
   mixin and the async/await transformer in some scenarios.

 - Writes a prototype of kernelForBuildUnit (although no automated tests for it
   yet).

 - Moves a few more pieces to ProcessedOptions

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2893493004 .
2017-05-19 13:59:15 -07:00
Sigmund Cherem ebfd044456 Remove async modifier from outlines
In the future we might want to re-add this, but for now, no one needs to know
that a function was async/async*/sync*. This also allows the async/await
transformer to ignore external references without any special logic.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2888823004 .
2017-05-18 15:20:20 -07:00
Régis Crelier dc1fd61f6d Fix fasta tests expectation after arguments descriptor change.
Review-Url: https://codereview.chromium.org/2890263002 .
2017-05-18 15:03:06 -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
Peter von der Ahé 4880a2876e Rewrite mixin application handling in Fasta.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2862223002 .
2017-05-09 09:22:57 +02: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
Konstantin Shcheglov f7c8c7e3ef Infer AsExpression types.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2862043002 .
2017-05-04 13:27:47 -07:00