Commit Graph

6018 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
Dan Rubel 8928329339 improve fasta interpolation recovery
* improve fasta interpolation recovery by adding closing brace
    for unterminated string
* update analyzer scanner test because fasta does not support
    does not support \r line endings

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2910583002 .
2017-05-26 08:43:48 -04: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
Konstantin Shcheglov 30b51f7403 Files are added with absolute URIs, but invalidated with file URIs.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2907673002 .
2017-05-25 13:42:18 -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
Peter von der Ahé 9b4bc8b0ff Read file names from libraries.json, not URIs.
R=danrubel@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2906673002 .
2017-05-25 16:20:05 +02:00
Peter von der Ahé bcb2ea962b Complain about function literals not being constant expressions.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2899343002 .
2017-05-25 16:02:30 +02:00
Peter von der Ahé 27761fd369 Read SDK and patches from a JSON file.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2895983002 .
2017-05-25 15:57:57 +02: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
Dan Rubel 54d6e3a1c5 cleanup fasta token classes
* replace fasta.SymbolToken --> analyzer.Token
* replace fasta.BeginGroupToken --> analyzer.BeginToken
* replace fasta.SymbolToken.eof --> analyzer.Token.eof

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2899043006 .
2017-05-25 07:26:50 -04:00
danrubel 498a39ed61 delete obsolete scanner roundtrip test
Review-Url: https://codereview.chromium.org/2900303003 .
2017-05-24 21:07:25 -04:00
Konstantin Shcheglov 97d587520c Add LimitedBinaryPrinter, tests and switch incremental generator to it.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2896493002 .
2017-05-24 16:17:28 -07:00
Konstantin Shcheglov 2b8fd9dee8 Transform async code only for source libraries.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2905463002 .
2017-05-24 15:51:18 -07:00
Dan Rubel 136698a734 remove fasta <--> analyzer token translation
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2902813005 .
2017-05-24 17:34:08 -04:00
Dan Rubel dff793d05f update lazy assignment operators
and remove scanLazyAssignmentOperators flag

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2903063003 .
2017-05-24 17:05:02 -04:00
Paul Berry a21b9e5638 Remove AstFactory from the front end.
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2904673003 .
2017-05-24 11:28:12 -07:00
Sigmund Cherem 9fd47a08d1 Address follow up comments
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2902643002 .
2017-05-24 11:20:40 -07:00
Sigmund Cherem 5f8bc4feb2 fasta: revert check for null fileUri in the error reporting of the verifier.
(as discussed in https://codereview.chromium.org/2894283002, we are reverting
this because we don't know how to reproduce this issue anymore. When it comes up
again we can either fix the issue or re-revert and include an explanation).

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2902153003 .
2017-05-24 11:17:15 -07:00
Dan Rubel 6e981d0cbf enable analyzer scanner adapter generic method support
This turns on generic method support in the scanner adapter layer
and updates the token.offset when the analyzer scanner
is being used to parse generic method comments.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2900963009 .
2017-05-24 13:37:52 -04: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 b9b949f436 Use FutureOr as the return context in async closures.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2898373004 .
2017-05-24 08:24:13 -07:00
Peter von der Ahé ddf5fc23f1 Improve analysis coverage.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2904483002 .
2017-05-24 15:52:42 +02:00
Paul Berry e642722f42 Implement subtyping rules for FutureOr in kernel.
These rules are only enabled when in strong mode, so existing Dart 1.0
functionality should be unaffected.

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

Review-Url: https://codereview.chromium.org/2900113002 .
2017-05-24 06:14:22 -07:00
Peter von der Ahé 61d855bb47 Prepare for development branch by updating externally-used API.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2898183002 .
2017-05-24 14:32:45 +02:00
Peter von der Ahé 9ed1ba2c12 Temporarily uncomment logEvent to make build bot green.
Review-Url: https://codereview.chromium.org/2901273002 .
2017-05-24 12:04:19 +02:00
Peter von der Ahé f5012090f9 New parser event needed to check case expressions.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2900993002 .
2017-05-24 11:48:42 +02:00
Peter von der Ahé b6a78795e4 Fix various semantic nits that Fasta will detect.
R=johnniwinther@google.com, paulberry@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2897003003 .
2017-05-24 11:43:18 +02:00
Peter von der Ahé 9eb265439f Ensure DART_CONFIGURATION is exported and don't run code in checked mode.
R=paulberry@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2903593002 .
2017-05-24 11:20:45 +02:00
Peter von der Ahé e6a7a38022 Support being called as absolute path.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2896033002 .
2017-05-24 11:07:53 +02: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 a3e11d2e6e Always record inference of implicit function expression params, even if dynamic.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2904653002 .
2017-05-23 12:32:49 -07:00
Paul Berry 0d31c8c524 Populate TypeInferrerImpl.closureContext more frequently.
Previously, we only used a ClosureContext in the case where the
innermost function being inferred was a function expression.  This
meant that we couldn't use the declared return type as the context for
`return` or `yield` statements in any other sort of function.  As a
first step towards fixing that, this CL makes the following changes:

- The entry point to type inference is now a separate
  TypeInferrer.inferFunctionBody method rather than re-using
  TypeInferrer.inferStatement; this gives us an opportunity to set up
  the context.

- Some of the logic from KernelFunctionExpression._inferExpression
  (particularly to do with asynchronous and generator functions) is
  moved to ClosureContext so that it can be used for other sorts of
  functions.

- The only time TypeInferrerImpl.closureContext is ever `null` is now
  when inferring a top level or field initializer expression, so we
  can eliminate some null checks from
  KernelReturnStatement._inferStatement and
  KernelYieldStatement._inferStatement.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2902683004 .
2017-05-23 11:21:45 -07:00
Konstantin Shcheglov 77d4eb609b Use LibraryIndex in CoreTypes instead of extending it.
A smaller step this time - change only clients, but keep implementation
the same for now.

Not all patched SDKs have all classes and procedures, so I have to make
some them lazy. All of them could be done for consistency, but this
might slightly affect performance for often used dart:core classes.

Also it's a bit of mess now.
Maybe group these classes into logical structures, coreTypes.core.list,
coreTypes.async.future, coreTypes.async.futureMicrotask, etc. Something
like it was before this change, but fixed types and names instead of
more flexible (but in general slower) strings.

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

Review-Url: https://codereview.chromium.org/2890933002 .
2017-05-23 09:30:37 -07:00
Konstantin Shcheglov 0cfdae6182 Beef up front-end mock SDK libraries, mostly dart:core.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2893423002 .
2017-05-22 14:49:55 -07:00
Konstantin Shcheglov b14be9d1ce Add a test for including all libraries from changed to the entry point.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2899883002 .
2017-05-22 14:44:47 -07:00
Konstantin Shcheglov 5139a1f85c Move the check for 'locals hides exports' to DillLibraryBuilder.buildAmbiguousBuilder().
R=ahe@google.com
BUG=

Review-Url: https://codereview.chromium.org/2893383002 .
2017-05-22 13:07:43 -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
Konstantin Shcheglov 3859d2eb71 Let printProgramText() to use filter to print only some libraries.
As requested in https://codereview.chromium.org/2886233002/ comment.

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

Review-Url: https://codereview.chromium.org/2893233003 .
2017-05-22 11:10:56 -07:00
Peter von der Ahé 6715900e09 Fix incremental kernel generator.
Review-Url: https://codereview.chromium.org/2896003002 .
2017-05-22 18:01:50 +02: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