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 .
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 .
- 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 .
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 .
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 .
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 .
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 .
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 .
* 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 .
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 .
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 .