Commit Graph

2004 Commits

Author SHA1 Message Date
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
Konstantin Shcheglov 43cea08f6d Fixes for review comments.
R=sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2889463002 .
2017-05-16 17:27:37 -07:00
Konstantin Shcheglov e3f4ed94b1 Rename Target.writeOutline() into computeOutline(), add separate KernelTarget.writeOutline().
For DillTarget write does not make sense, and even for KernelTarget
we usually don't want to write anything.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2885923002 .
2017-05-16 14:38:24 -07:00
Konstantin Shcheglov 87680e5923 Fix computing export scopes for library cycles and after loading.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2885883002 .
2017-05-16 11:37:57 -07:00
Konstantin Shcheglov 97cf17c322 Compute export namespaces for DILL libraries.
R=ahe@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2886563002 .
2017-05-16 10:02:43 -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
Dan Rubel 278c7bfbeb merge fasta.Token into analyzer.Token
This eliminates much of the duplication between the two token hierarchies
by merging much of the fasta.Token hierarchy into the analyzer.Token.

* merge token hierarchies
* cleanup fasta.Token.copy()
* set preceedingComments field via constructor
* replace isBuiltInIdentifier --> type.isBuiltIn
* change all fasta.Token references to analyzer.Token
* move fasta.Token.value() implementation into analyzer.SimpleToken

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2890523002 .
2017-05-16 11:50:14 -04:00
Konstantin Shcheglov e118615103 Include only changed or affected libraries into delta.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2885743002 .
2017-05-16 08:49:48 -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
Dan Rubel d566906167 cleanup unused incremental resolution
* remove unused analyzer incremental resolution
* remove unused Token.applyDelta method

Patch Set 1 is the original CL that was landed and reverted
https://codereview.chromium.org/2876993005

Patsh Set 2 contains additional fixes and test changes

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2884853002 .
2017-05-16 07:53:17 -04: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
Konstantin Shcheglov b3837a5e28 Enhance DirectiveListener to collect import/exports with combinators.
We need combinators to build export scopes for DILL libraries.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2884783002 .
2017-05-15 13:59:14 -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
Dan Rubel d644be82ab Revert "cleanup unused incremental resolution"
This reverts commit 77b383e6b8.

Review-Url: https://codereview.chromium.org/2887443002 .
2017-05-15 11:01:57 -04:00
Dan Rubel 77b383e6b8 cleanup unused incremental resolution
* remove unused analyzer incremental resolution
* remove unused Token.applyDelta method

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2876993005 .
2017-05-15 09:09:25 -04: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
Konstantin Shcheglov 8bf0b9092a Skip native clauses when parsing directives.
Otherwise we cannot parse SDK libraries to build full graph.

R=ahe@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2879063002 .
2017-05-14 11:21:13 -07:00
Konstantin Shcheglov 396d72be4c Start actually adding incrementality into incremental kernel generator.
We now store and reuse resolved kernel libraries.
Existing tests are not yet check this, I will add this in future CLs.

Also returned ProgramDelta(s) are still not deltas, but full bundles.

R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2877193003 .
2017-05-12 19:58:36 -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
Konstantin Shcheglov 02cb71685e Move flat_buffer and api_signature into front_end.
I will need to use these in front_end to store precomputed information
and computing combined signatures.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2875373002 .
2017-05-12 10:48:28 -07:00
Konstantin Shcheglov bdedd6768b Add a way to use shared CanonicalName root to deserialize Program.
This allows for example to add SDK into a Program, then load the
"incomplete" Program A that has only the library A, and name sequences
that references SDK classes. Because we look into the nameRoot which
aleady has SDK CanonicalName(s), we can find these names while filling
the link table and use references which point to the existing SDK
AST nodes.  Then we can load another set of library cycles, etc.

At the end we have a set of self-consistent libraries that we can
feed into DillTarget/DillLoader and resolve anothersource target
against it.

This CL is based on https://codereview.chromium.org/2872903005/
which has not been reviewed yet.

R=kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2874723002 .
2017-05-12 10:42:08 -07:00
Konstantin Shcheglov 25e8941cc7 Compute topologically sorted library cycles.
In following CLs we will compile (or load already compiled) kernels
for each cycle and compile following cycles against them.

R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2879783002 .
2017-05-12 08:41:48 -07:00
Sigmund Cherem db331244d0 Generate outline without transformations in patched_sdk, use it for unit tests
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2881603003 .
2017-05-11 15:10:33 -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
Konstantin Shcheglov 8751b91062 Rework DillLoader to allow adding multiple dills.
This allows us to compose a consistent bundle with SDK and the transitive
closure of required libraries for a libarary, and then compile it
separately (or as a part of its own library cycle).

There is still more data public than I'd like, but I will leave this
clean up fo later.

R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2872903005 .
2017-05-11 08:56:36 -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
Konstantin Shcheglov 114f49dcab Add the test for updating a part.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2876643002 .
2017-05-10 14:20:35 -07:00
Konstantin Shcheglov 176c7d7303 Replace factory constructor with a static method for creating IncrementalKernelGenerator.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2869273006 .
2017-05-10 13:10:11 -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 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
Konstantin Shcheglov bd1ee32543 Move [file_]byte_store.dart into pkg/front_end/test/src/incremental/.
We are going to reuse ByteStore in front_end, also for incremental
compilation.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2869803004 .
2017-05-09 09:12:15 -07:00
Konstantin Shcheglov 6e7d280a83 (Reland) Start using FileState/FileSystemState to provide consistent view.
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2871783002 .
Review-Url: https://codereview.chromium.org/2865253003 .
2017-05-09 09:04:40 -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 6b9b2146ed Clean up type inference methods.
Several minor changes that shouldn't affect functionality:

- inferGenericFunctionOrType no longer returns the inferred type;
  instead, it fills an "inferredTypes" array with the inferred type
  arguments.

- Downwards inference is signaled to inferGenericFunctionOrType by
  passing `null` for `formalTypes` and `actualTypes`.

- inferTypeFromConstraints no longer falls back on
  instantiateToBounds.  This never could have had any effect anyway
  because it was only invoked for upwards inference, and in that case,
  all type arguments are already known.

- Inferred type arguments are now passed back to
  KernelConstructorInvocation as a list rather than forcing it to
  extract them from the inferred class type.  If the inferred class
  type doesn't need to be computed, it isn't.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2869003002 .
2017-05-09 05:52:40 -07:00
Erik Corry de0f220b7d Revert "Start using FileState/FileSystemState to provide consistent view."
This reverts commit 6173ac476b.
Failure on analyzer test: python tools/test.py -mrelease --checked -t60
--use-sdk pkg/front_end/test/subpackage_relationships_test

BUG=
TBR=scheglov@google.com

Review-Url: https://codereview.chromium.org/2864243004 .
2017-05-09 09:21:24 +02:00
Dan Rubel 81d25f4c71 more work aligning fasta.Token with analyzer.Token
* move isPseudo getter out of Token into TokenType
* move special case charCount logic out of fasta.Token into fasta.ErrorToken
* move more accessors from fasta.Token into analyzer.Token
* add @overrides to denote which methods have been declared in analyzer.Token
* make fasta LazySubstring and its subclasses private
* rename fasta.previousToken to previous to match analyzer.Token
* flatten fasta.Token.preceedingCommentTokens into preceedingComments
* normalize fasta.Token.next and analyzer.Token.next

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2872433005 .
2017-05-09 00:09:56 -04:00
Konstantin Shcheglov 6173ac476b Start using FileState/FileSystemState to provide consistent view.
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2871783002 .
2017-05-08 17:17:19 -07:00
Paul Berry e3cb466a5f Add a "skipVm" option to fasta tests.
This makes it easy to identify tests that pass in Fasta but fail in
the VM.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2869953002 .
2017-05-08 16:10:21 -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 d34d4e545c Change front end type inference algebra to match analyzer.
This CL swaps the behavior of greatest and least closure in
solveTypeConstraint.  It also changes greatestClosure(?) to `dynamic`
rather than `Object`.

These changes bring front end type inference more closely into line
with analyzer type inference.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2872763002 .
2017-05-08 14:19:11 -07:00
Konstantin Shcheglov 9167ad0f55 Update DeltaProgram API and documentation.
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2871573003 .
2017-05-08 14:13:13 -07:00
Dan Rubel 3347169016 cleanup TokenType var names
* rename TokenType info --> type
* rename fasta Token.info --> Token.type

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

Review-Url: https://codereview.chromium.org/2872453004 .
2017-05-08 12:43:08 -04:00
Konstantin Shcheglov 9acca5f464 Initial version of Fasta based IncrementalKernelGenerator.
No incrementality yet.
In a separate experiment I can load SDK kernel and resolve against it.
So, I will add it in a following CL, or maybe even generalize to any library.

R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2869563002 .
2017-05-08 09:19:26 -07:00