Commit graph

1142 commits

Author SHA1 Message Date
Paul Berry 6855bd28f8 Remove hack from KernelTypeInferrer.inferInitializer.
Now that all constructor initializers created by BodyBuilder implement
KernelInitializer, we no longer need a hack to skip initializers that
don't.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2992423002 .
2017-08-07 14:03:44 -07:00
Paul Berry 41170b0a15 When reordering constructor initializers, use correct types for temp vars.
In strong mode, when a call to a super-initializer is reordered, we
can use the static type of the super-initializer arguments to set the
types of the temporary variables that we use to do the reordering.
This is desirable because it might help avoid unnecessary casts.

In non-strong mode, we use `dynamic` for the temporary variables, to
replicate Dart 1.0 behavior.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2993193002 .
2017-08-07 13:55:40 -07:00
Paul Berry 107335c1d0 Add type inference for invalid constructor initializers.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2998573002 .
2017-08-07 13:37:27 -07:00
Konstantin Shcheglov 5011b024df Replace fake directories with actual createDirectory().
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2994683002 .
2017-08-07 13:25:16 -07:00
Paul Berry 89c910b9c1 Move byte_store.dart and file_byte_store.dart to their own subdirectory.
This allows us to use the subpackage relationships test to verify that
they don't import any other parts of front_end, which paves the way
for the possibility of moving them to their own package in the future.

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

Review-Url: https://codereview.chromium.org/2990323002 .
2017-08-07 11:04:48 -07:00
Konstantin Shcheglov c28419bce0 Add support for SDK outline in KernelDriver.
I had to weaken file system createDirectory() to avoid conflicts when
we re-create SDK, and attempt to re-recreate its directory.

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

Review-Url: https://codereview.chromium.org/2993093003 .
2017-08-07 10:46:44 -07:00
Paul Berry ae4cbb50af Use "bool" as the downward inference context for assert conditions.
This addresses the type inference part of #30326.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2997513002 .
2017-08-07 10:36:51 -07:00
Sigmund Cherem b48584d3d0 Switch FE to use the libraries.json format.
This CL:
  * introduces the Dart API to operate over libraries specifications and describes
    the format we intend to use (see libraries_spec.dart)

  * implements serialization/deserialization for this API

  * switches over the front_end to use these APIs
    * public options accept a URI to the JSON file and no longer
       accept a `dartLibraries` map
    * internal code uses the LibrariesSpecification API

  * switches other dependencies on these APIs (resynthesizer_test and patch_sdk.dart)

This is the first step in migrating over to use the libraries.json format and
eventually remove the patched_sdk step. In particular, some of the next steps
include:
  * add a build step to generate .json files from .yaml files
  * add a libraries.yaml file for the sdk
  * split the patched_sdk step in two:
     * patching files
     * generating .dill files
  * add any missing support for patch-files in fasta
  * finally remove the patching files step, and only have a build step for generating
   .dill files

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

Committed: abf2d23af2
Review-Url: https://codereview.chromium.org/2986303003 .
2017-08-07 08:41:28 -07:00
Peter von der Ahé dbe482caac Share code for parsing local functions.
R=danrubel@google.com, johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2999523002 .
2017-08-07 16:06:04 +02:00
Peter von der Ahé 98422979ac Parse type variables of local functions before return type.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2985673002 .
2017-08-07 13:46:47 +02:00
Sigmund Cherem b6d08264a3 Revert "Switch FE to use the libraries.json format."
This reverts commit abf2d23af2.

Reason for revert:
 - win build failed in patched_sdk (likely storing paths and not uris)
 - dart2js bots failed (missing flag)

Will fix the issues and reland shortly.

Review-Url: https://codereview.chromium.org/2993113003 .
2017-08-04 19:46:17 -07:00
Paul Berry 1b9ba53fb6 Implement type inference for asserts in constructor initializers.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2995553002 .
2017-08-04 17:55:11 -07:00
Sigmund Cherem abf2d23af2 Switch FE to use the libraries.json format.
This CL:
  * introduces the Dart API to operate over libraries specifications and describes
    the format we intend to use (see libraries_spec.dart)

  * implements serialization/deserialization for this API

  * switches over the front_end to use these APIs
    * public options accept a URI to the JSON file and no longer
       accept a `dartLibraries` map
    * internal code uses the LibrariesSpecification API

  * switches other dependencies on these APIs (resynthesizer_test and patch_sdk.dart)

This is the first step in migrating over to use the libraries.json format and
eventually remove the patched_sdk step. In particular, some of the next steps
include:
  * add a build step to generate .json files from .yaml files
  * add a libraries.yaml file for the sdk
  * split the patched_sdk step in two:
     * patching files
     * generating .dill files
  * add any missing support for patch-files in fasta
  * finally remove the patching files step, and only have a build step for generating
   .dill files

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

Review-Url: https://codereview.chromium.org/2986303003 .
2017-08-04 17:41:27 -07:00
Konstantin Shcheglov f5d2688206 Add documentation comments for enum and enum values. Resynthesize in analyzer.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2997473002 .
2017-08-04 16:53:52 -07:00
Stephen Adams bb1e91b597 Redo "Work-around for missing mixin-application charOffset"
TBR=sigmund@google.com

BUG=

Review-Url: https://codereview.chromium.org/2991403002 .
2017-08-04 15:35:38 -07:00
Konstantin Shcheglov 4ef7fd14c1 Record Typedef reference into Kernel FunctionType and resynthesyze typedefs in Analyzer.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986393002 .
2017-08-04 12:02:26 -07:00
Konstantin Shcheglov 41bcfaa4a4 Add createDirectory() to MemoryFileSystemEntity.
We need this API to create a mock SDK in a way that makes
ProcessedOptions.validateOptions() to accept it - the SDK root
must exist.

Alternatively (or in addition to) we could make writeXYZ create parent
directories implicitly. So, to "create" a directory, you would need
to create a file in this directory.

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

Review-Url: https://codereview.chromium.org/2994643002 .
2017-08-04 11:46:02 -07:00
Paul Berry 1b03375d62 Implement type inference for super initializers.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2992263002 .
2017-08-03 19:39:13 -07:00
Stephen Adams 9442c1cf44 Revert "Work-around for missing mixin-application charOffset"
This reverts commit 2007487cf0.

Needs status file changes.

TBR=sigmund@google.com

BUG=

Review-Url: https://codereview.chromium.org/2992993002 .
2017-08-03 16:43:35 -07:00
Stephen Adams 2007487cf0 Work-around for missing mixin-application charOffset
BUG=
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2994553002 .
2017-08-03 14:47:31 -07:00
Paul Berry 867d682ff5 Test type inference for field initializers using "this." syntax.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2986403002 .
2017-08-03 14:32:06 -07:00
Paul Berry 57d71479e1 Perform type inference on constructor field initializer expressions.
Fixes #30251

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2994533002 .
2017-08-03 13:54:36 -07:00
Konstantin Shcheglov 60a576108c Store parts in Kernel Library, resynthesize parts in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988373002 .
2017-08-03 10:36:29 -07:00
Konstantin Shcheglov 58df70b83b Get logger / fileSystem / byteStore from ProcessedOptions.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2992173002 .
2017-08-01 16:19:59 -07:00
Sigmund Cherem d66294cfe2 Pass additional options in incremental setup
With this, we can infer the .packages file on disk.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2989223002 .
2017-08-01 15:00:38 -07:00
danrubel 5909efe401 Fix scanning of unterminated strings
This fixes
* lineStart tracking when synthetic strings added
* token charOffset when scanning UTF-8 stream

These changes prevent the crashes mentioned in
#29976 and #29982.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2984713002 .
2017-08-01 17:31:07 -04:00
Konstantin Shcheglov f9424908a5 Issue 30034. Parse annotations for typedef(s) and resynthesize from Kernel in analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG= https://github.com/dart-lang/sdk/issues/30034

Review-Url: https://codereview.chromium.org/2987983004 .
2017-08-01 10:08:34 -07:00
Sigmund Cherem e1bccfc857 FE: let targets override whether imports to internal platform
libraries (dart:_foo) are allowed.

Override this in Dart2jsTarget to allow it in the dart2js_native test suite.

R=sra@google.com

Review-Url: https://codereview.chromium.org/2992073002 .
2017-07-31 15:23:12 -07:00
Konstantin Shcheglov 66663f7fd6 Add optional FunctionType.positionalParameterNames and use them to resynthesize function-type formal parameters in Analyzer.
This will be also used as an alternative approach to support of
typedefs in Analyzer. The previous one was reverted in
e431e93e87, because it caused problems
during storing parameters of generic Function(s).

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

Review-Url: https://codereview.chromium.org/2985293002 .
2017-07-31 14:09:21 -07:00
Sigmund Cherem 13a4906be9 Kernel driver: pass options and use it for its compiler context
This ensures we don't accidentally override options (e.g. strongMode was being
overriden accidentally as a result).

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2992773002 .
2017-07-31 13:22:50 -07:00
Konstantin Shcheglov e64115f93f Add Class.isEnum to Kernel and use it to resynthesize enums in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2988113002 .
2017-07-31 10:35:03 -07:00
Konstantin Shcheglov 28d774a792 Resynthesize combinators for import/export directives from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2992053002 .
2017-07-31 10:02:55 -07:00
Konstantin Shcheglov ea876bd780 Reapply 47ecf72 after it was reverted in e431e93e87.
There was a conflict with the problematic afc392b, so it was reverted
too. But 47ecf72 per se does not cause dartk failures. This runs
without failures.

python tools/test.py -m release -c dartk --builder-tag no_ipv6 language/

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

Review-Url: https://codereview.chromium.org/2991993002 .
2017-07-28 09:48:51 -07:00
pq 7370c8f749 front_end analyzer dev dependency.
To satisfy dependencies, for example, in `tool/perf.dart`.

Duplicate of https://codereview.chromium.org/2985143002/ (which fails to land).

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2992633004 .
2017-07-28 06:38:10 -07:00
Erik Corry e431e93e87 Revert two Kernel changes that were causing test failures.
Example failure:
python tools/test.py -m release -c dartk --builder-tag no_ipv6 \
    language/function_type/function_type63_test

Revert "Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel."
This reverts commit afc392b66d.
Reverts https://codereview.chromium.org/2990783002

Revert "Add Member.documentationComment and use it to resynthesize documentation from Kernel."
This reverts commit 47ecf72272.
Reverts https://codereview.chromium.org/2990873002

Also reverts some attempts to fix test files:
302b410364
https://codereview.chromium.org/2984343002
05ccf27015
https://codereview.chromium.org/2992683002
f71dcd7834
https://codereview.chromium.org/2984363003

Also had to revert some test changes that were committed on top of a red buildbot, in order to try to get back to a place where bots were green:

23952fdf56
https://codereview.chromium.org/2990773002
557cab2a3e
https://codereview.chromium.org/2985173002

R=johnniwinther@google.com, karlklose@google.com
BUG=

Review-Url: https://codereview.chromium.org/2986093002 .
2017-07-28 14:08:23 +02:00
Konstantin Shcheglov 47ecf72272 Add Member.documentationComment and use it to resynthesize documentation from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990873002 .
2017-07-27 15:22:48 -07:00
Konstantin Shcheglov afc392b66d Serialize typedef parameters (including function typed ones) to Kernel and use it to resynthesize typedefs from Kernel.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990783002 .
2017-07-27 11:53:15 -07:00
Konstantin Shcheglov f603889766 Store dependency libraries canonical names during limited store.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991873002 .
2017-07-27 11:22:05 -07:00
Sigmund Cherem 92481e9b34 Add dump-partial tool.
This script lets you dump as text a partial .dill file generated by the
incremental generator. To do so, it requires that you pass in other .dill files
that are needed (in order).

In the context of a hot-reload test, you should be able to run this as follows:

pkg/front_end/tool/fasta dump-ir newProgram.dill fullProgram.dill platform.dill

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2985113002 .
2017-07-26 15:19:42 -07:00
pq 6e45682ebb Analyzer 0.31.0-alpha.0
For analyzer, front_end and kernel packages:

* bump alpha versions
* update SDK constraints

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2985103002 .
2017-07-26 13:18:14 -07:00
Konstantin Shcheglov 8a08dbd08e Add export dependencies to Kernel libraries and use them to resynthesize ExportElement(s) in Analyzer.
R=ahe@google.com, brianwilkerson@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991753002 .
2017-07-26 12:33:19 -07:00
Dan Rubel 0b93c279e7 improve fasta closing brace recovery
Currently, fasta synthetically closes open braces until it finds
a match for the current closing brace. This works most of the time,
but provides less than optimal recovery in some common cases.
For example, given the following

class { foo()){print(a);} var a = 'hello'; }

the current brace recovery method fails to find any match for the
second closing parenthesis and synthetically closes the class
causing the rest of the file to be parsed as outside the class.

With this CL, fasta still synthetically closes open braces when it finds
a match for the current closing brace, but if there is no match, then
it just skips over the extra closer and continues. This approach dramatically
improves recovery in many cases where there is an extra closing parenthesis
or extra closing square bracket. In the example above, fasta parses
everything after the second closing parenthesis inside the class.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2981343002 .
2017-07-26 10:37:19 -04:00
Konstantin Shcheglov e0658b18a3 Resynthesize constructor initializers from Kernel.
We don't resynthesize assert initializers yet, because they are
compiled into an unholy mess.

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

Review-Url: https://codereview.chromium.org/2983413002 .
2017-07-25 09:24:13 -07:00
Konstantin Shcheglov 2d01f1f8d9 Parse documentation for class aliases, fix for /// comments.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2990523002 .
2017-07-24 22:15:37 -07:00
Konstantin Shcheglov 72d14b8202 Replace typed_mock with mockito in front_end.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2984123002 .
2017-07-24 11:46:18 -07:00
Sigmund Cherem c6600c08d3 Remove FileSystem.lastModified
It is no longer in use.

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2988443002 .
2017-07-21 11:45:56 -07:00
Paul Berry c057f091c2 Implement AstBuilder integration for method/function invocations.
This is tricky because there isn't a clean correspondence between
analyzer's AST (which reflects user syntax) and kernel representation.
For example:

  f(args);

could be a call to a static function f, a method f in the current
class, or an invocation of a function-typed object stored in a
variable called f.  ResolutionStorer operates on the kernel
representation, so it sees the difference, but ResolutionApplier
operates on the analyzer AST, so it does not.  So we go to some extra
work to make sure a type is stored for f, regardless of whether f is a
function, method, or a variable.  This requires some re-ordering logic
in ResolutionStorer, since the inferred type of f is not known until
after the args have been visited.

The implementation is not complete; currently the type that we store
in the first two cases is `dynamic` because the type inference
mechanism doesn't preserve enough information to allow us to determine
the correct type; this will be remidied in a future CL.

A similar situation occurs for:

  x.m(args);

which could be a call to a method m in the object x, or an invocation
of a function-typed object returned by the getter m in the object x.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2984013002 .
2017-07-21 10:47:25 -07:00
Konstantin Shcheglov ebd3ed5ade Resynthesize mixins from Kernel.
This adds Class.isSyntheticMixinImplementation flag which is set
to 'true' for synthetic X&Y classes.

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

Review-Url: https://codereview.chromium.org/2982373002 .
2017-07-21 10:29:46 -07:00
Konstantin Shcheglov 2289ce12ae Add import dependencies to Kernel libraries and use them to resynthesize ImportElement(s) in Analyzer.
R=ahe@google.com, kmillikin@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2987553002 .
2017-07-21 09:21:57 -07:00
Paul Berry cc97126aed Implement AstBuilder integration for parenthesized expressions.
The type inference engine doesn't even see parenthesized expressions
as a separate entity, since parentheses don't have any semantics.  So
we just copy the static type from the enclosed expression.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2982323003 .
2017-07-20 13:49:20 -07:00