Commit Graph

2004 Commits

Author SHA1 Message Date
danrubel b8b9e3eae4 add test for internal scanner API
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2952153003 .
2017-06-23 12:35:09 -04:00
Peter von der Ahé f1b7a97744 Move testing.json and status files to more natural locations.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2957623002 .
2017-06-23 14:27:53 +02:00
Peter von der Ahé 2434dc606a Add regression tests from Luke's bug reports. Part 1.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2955443002 .
2017-06-23 14:25:26 +02:00
Paul Berry dd0a00f581 Infer the return types of local functions where appropriate.
Note that we do this in order to be consistent with type inference of
function expressions.  See https://codereview.chromium.org/2209293002.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2950213002 .
2017-06-22 12:17:10 -07:00
Paul Berry 348b42c98b Properly type infer for-in loops when the iterator type is a type parameter.
Also, fix a minor bug in variable declaration inference that was
preventing a local variable without an initializer from having its
type properly "inferred" as `dynamic`.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2949093002 .
2017-06-21 14:46:54 -07:00
Paul Berry b2c4b0ac0a Implement override-based type inference for instance methods.
Also, fix a rare infinite loop bug in analyzer exposed by one of the
tests.

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

Review-Url: https://codereview.chromium.org/2946273002 .
2017-06-21 13:56:04 -07:00
Paul Berry d514347a44 Add type inference for null-aware method invocations.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2950923002 .
2017-06-20 12:16:34 -07:00
Paul Berry be01632bc0 Fix type inference of getters that "override" setters and vice versa.
Normally getters and setters are considered distinct and unrelated by
the type inference algorithm.  However, if a getter has no declared
type and doesn't override anything, then we fall back on inferring its
type from an inherited setter, and vice versa.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2946733003 .
2017-06-20 05:34:31 -07:00
Paul Berry 8bb13b8740 Verify that inference ignores setters with function-typed arguments.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2948693002 .
2017-06-19 15:14:27 -07:00
Paul Berry a4743540d0 Implement type inference for null-aware property gets.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2944933002 .
2017-06-19 15:08:56 -07:00
Paul Berry fdf77ba36f Implement type inference for if-null expressions (a ?? b).
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2944903002 .
2017-06-19 13:46:09 -07:00
Paul Berry 7939ea00ef Implement type inference of getters/setters based on inheritance.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2943273002 .
2017-06-18 16:35:02 -07:00
Paul Berry ba14751f55 Implement override-based inference of instance fields.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2938423003 .
2017-06-17 06:27:27 -07:00
Siva Chandra 7087085505 Fix frontend tests after bac83e0973
R=nweiz@google.com

Review-Url: https://codereview.chromium.org/2943173002 .
2017-06-16 14:05:08 -07:00
Konstantin Shcheglov 8154d623d6 Test for the case when the watch function is null.
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2936313003 .
2017-06-16 09:10:03 -07:00
Paul Berry 953399512a Enable top level inference of instance property gets/sets.
To facilitate experimentation, I've left the old code in place, but
disabled it using a const bool `fullTopLevelInference`.  The old code
can be re-enabled by setting this bool to `false`.  Once we are sure
that we want to proceed with this approach, we can remove the old
code.

I believe that with this change, all expressions that can be type
inferred inside a method body can now be type inferred at top level,
provided that there are no circular dependencies.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2942153002 .
2017-06-15 20:51:19 -07:00
Paul Berry 79bf5f5931 Fuse top level type inference with dependency generation.
This CL combines the two parts of top level type inference
(determining dependencies and inferring a type) into a single
operation.

The technique is: instead of evaluating top level types in
topologically sorted order (which requires that we figure out the
dependencies first, so that we can do topological sorting), we simply
iterate over the fields requiring inference and begin inferring them
in whatever order they are encountered.  If, while trying to infer the
type of one field, we discover a reference to field that hasn't been
type inferred yet, we make a recursive call to infer the second field.
If this recursion leads to a loop, then we mark all of the fields in
the loop as participating in a circularity (and set their types to
`dynamic` for error recovery purposes).

To facilitate experimentation, I've left the old code in place, but
disabled it using a const bool `fusedTopLevelInference`.  The old code
can be re-enabled by setting this bool to `false`.  Once we are sure
that we want to proceed with this approach, we can remove the old
code.

Note that there are some minor user-visible behavioral changes:

- When there is a circularity, we no longer consider the entire
  strongly connected component to be part of the circularity; we only
  consider the loop formed by following the first unresolved
  dependency of each field.  (I did this because of ease of
  implementation, and because it made it easier to reassure myself
  that the outcome of the algorithm is independent of the order in
  which fields are visited).  See
  pkg/front_end/testcases/inference_new/strongly_connected_component.dart
  for the user-visible consequence of this change.

- We no longer need to speculatively assume that method invocations
  depend on the types of their parameters when not supplying generic
  types; now they only depend on the types of their parameters when
  the method being invoked is known to be generic.  See
  pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart.

- We no longer need to speculatively assume that invocations of `+`,
  `-`, `*`, and `%` depend on the types of their RHS; now they only
  depend on the types of their RHS when the type of the LHS is
  `int`. See
  pkg/front_end/testcases/inference_new/dependency_only_if_overloaded.dart.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2942623004 .
2017-06-15 18:13:51 -07:00
Paul Berry da3d611aaf Remove pkg/front_end's remaining dependencies on pkg/analyzer.
The remaining dependencies were in code that isn't being used anymore,
so I just removed the dead code.

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

Review-Url: https://codereview.chromium.org/2941083002 .
2017-06-15 13:47:29 -07:00
Paul Berry 6bc0baf131 Add checks to make sure new front_end package dependencies are not added.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2940893004 .
2017-06-15 11:18:57 -07:00
Peter von der Ahé b4066914eb Late night strong mode cleaning.
R=efortuna@google.com

Review-Url: https://codereview.chromium.org/2942763002 .
2017-06-15 09:44:50 +02:00
Peter von der Ahé 06b8ce5d34 More dart2js strong mode cleanup.
R=efortuna@google.com

Review-Url: https://codereview.chromium.org/2934333002 .
2017-06-15 09:42:22 +02:00
Paul Berry 44f19d1a60 Lift nearly all top-level type inference restrictions.
This CL lifts all of the restrictions on top level type inference
except for one: the restriction that expressions used for top level
type inference cannot depend on the types of instance getters,
instance setters, or instance fields.  (That restriction will be
lifted in a later CL).

The technique is: to determine the dependencies of an expression,
rather than recurse through the expression applying the rules for what
constitutes an "immediately evident" expression, we simply do a dry
run of the inference algorithm and record what static fields were
accessed.  To avoid recording bogus dependencies on fields whose type
doesn't matter, this dry run skips subexpressions whose type isn't
needed.

To facilitate experimentation, I've left the old code in place, but
disabled it using a const bool `extendedTopLevelInference`.  The old
code can be re-enabled by setting this bool to `false`.  Once we are
sure that we want to proceed with this approach, we can remove the old
code.

Note that this makes the behavior begin to diverge with analyzer
behavior, so I've created a new test directory:
pkg/front_end/testcases/inference_new/, to hold test cases which
aren't expected to match analyzer.  Analyzer is only tested against
the test cases in pkg/front_end/testcases/inference/.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2935323002 .
2017-06-14 20:34:06 -07:00
Konstantin Shcheglov a3d9f5303c Cache transitive files in FileState.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2937103002 .
2017-06-14 13:53:28 -07:00
Sigmund Cherem 5e5e62f9d8 Remove deps from reloader
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2937983002 .
2017-06-14 10:57:25 -07:00
Dan Rubel f8655ca568 update invalid hex digit recovery
* update invalid hex digit recovery for compatibility with analyzer
* address comments from https://codereview.chromium.org/2915093002

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2941583003 .
2017-06-14 11:18:34 -04:00
Konstantin Shcheglov 8925c68a71 Extract computing UnlinkedUnit(s) and cache them in ByteStore.
So, we usually don't have to parse most of the files in order to
compute imports/exports/parts and API signatures.

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

Review-Url: https://codereview.chromium.org/2939823002 .
2017-06-14 08:09:58 -07:00
Peter von der Ahé a189be6786 Copy fasta analyze_test to dart2js.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2942573002 .
2017-06-14 15:00:43 +02:00
Peter von der Ahé 6302a5b31b Implement metadata on classes and additional semantic checks.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2938793002 .
2017-06-14 14:59:53 +02:00
Peter von der Ahé 3c17c44d52 Implement metadata on methods and fields.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2935993002 .
2017-06-14 08:25:17 +02:00
Paul Berry 211e578273 Chase imports in analyzer's front_end_inference_test.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2936043002 .
2017-06-13 14:27:54 -07:00
Konstantin Shcheglov ba189d1fd3 Fix for mismatch between existing FileState data and UnlinkedUnit.
I started implementing using of UnlinkedUnit, and found that I like
isShow and names better. Also, parts are always only URIs. And I think
that we are not going to need setters.

R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2936833003 .
2017-06-13 13:33:23 -07:00
Paul Berry e2c2733556 Add expectations to infer_local_function_return_type.
Previously this test didn't really test anything.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2939523003 .
2017-06-13 13:31:12 -07:00
Paul Berry a1ecb46a4c Fix top level type inference for binary operators.
Multiple changes were required:

- The analyzer's mock SDK had an incorrect return type for
  `num.operator/`.

- We weren't considering the RHS of the binary operators `+`, `-`,
  `*`, and `%` to be an inference dependency (we need to, since the
  special overload rules for int depend on the type of the RHS).

- We weren't executing the overload logic when doing top level type
  inference.

- The logic for deciding what operators are overloaded was incorrect.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2940703002 .
2017-06-13 13:07:00 -07:00
Konstantin Shcheglov 0912f3c640 Use API signatures for library cycle signatures when possible.
If there are mixin applications, we still have to use full content hashes.

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

Review-Url: https://codereview.chromium.org/2939743002 .
2017-06-13 11:39:29 -07:00
Konstantin Shcheglov 751c71f034 Store also 'hasMixinApplication' flag with UnlinkedUnit.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2940673002 .
2017-06-13 11:20:04 -07:00
Konstantin Shcheglov fbaa7d45c4 FlatBuffers formats for storing unlinked units.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2939653002 .
2017-06-13 08:50:49 -07:00
Peter von der Ahé 73107ed49e Fix memory leak in test.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2940643002 .
2017-06-13 17:16:53 +02:00
Peter von der Ahé db2e915aac Improve recovery from compile-time errors.
R=danrubel@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2938573002 .
2017-06-13 16:00:15 +02:00
Peter von der Ahé 5095646191 Apply transformations after comparing to golden files.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2939533002 .
2017-06-13 09:40:35 +02:00
Peter von der Ahé b06a3602b4 Update golden files.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2933763002 .
2017-06-13 09:25:22 +02:00
Paul Berry 24bb748bc7 Implement type inference for "not" expressions.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2935763004 .
2017-06-12 17:44:25 -07:00
Konstantin Shcheglov c4de2886b1 Build reverse dependencies between LibraryCycle(s).
I plan using it for adding libraries that have not been affected by
the changed files, but must be sent to VM because of possible inlining.
We will find affected libraries and then climb up until we reach the
entry point.

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

Review-Url: https://codereview.chromium.org/2934933002 .
2017-06-12 17:30:52 -07:00
Paul Berry d4a64e52e7 Add type inference for assignments to this[...]
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2938443003 .
2017-06-12 14:00:59 -07:00
Paul Berry 5d58191948 Add type inference for assignments to super[...]
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2935783003 .
2017-06-12 13:34:38 -07:00
Konstantin Shcheglov 16833bce7c Add FileState.hasMixin/hasMixinLibrary properties.
We will use them to decide which kind of key to use for cache.

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

Review-Url: https://codereview.chromium.org/2928393004 .
2017-06-12 12:43:31 -07:00
Paul Berry cdb1e858d2 Add type inference for assignments to properties.
This covers explicit property accesses (using both `.` and `?.`) as
well as implicit properties of `this`.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2931363003 .
2017-06-12 11:33:06 -07:00
Konstantin Shcheglov e92aadb72f Report unused files to watch.
R=ahe@google.com, paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2933153002 .
2017-06-12 10:01:31 -07:00
Konstantin Shcheglov 5e8ceb60ab Implement GC for FileState(s).
Also fix for invoking watch().

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

Review-Url: https://codereview.chromium.org/2929363002 .
2017-06-12 08:48:03 -07:00
Peter von der Ahé 4e8203f9cd Improve error messages and recovery.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2924363002 .
2017-06-10 10:43:03 +02:00
Peter von der Ahé 043c0096ad Complain about use before declaration.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2924423003 .
2017-06-10 10:12:18 +02:00