Commit Graph

4770 Commits

Author SHA1 Message Date
Peter von der Ahé 28084d1f85 Don't peek when parsing mixin applications.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2957503003 .
2017-06-26 14:13:37 +02:00
Peter von der Ahé a1ad4e4feb Remove peeking from parseTypedef and parseClassOrNamedMixinApplication.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2948383002 .
2017-06-26 13:15:47 +02:00
Peter von der Ahé 2c53bcbf12 Document where the parser uses peeking.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2950393003 .
2017-06-26 10:17:42 +02:00
Erik Corry 029b1cb948 Spelling fixes e to i.
R=kevmoo@google.com
BUG=

Review-Url: https://codereview.chromium.org/2957593002 .
2017-06-24 13:41:39 +02:00
Paul Berry 3b6f276c84 Implement inference tests for logical operators.
The tests for this are placed in inference_new because the analyzer
implemenation doesn't do proper downward inference.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2956723002 .
2017-06-23 14:47:41 -07:00
Paul Berry 2d0bfe2d54 Resolve type parameter bounds when looking up interface members.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2954133002 .
2017-06-23 14:39:19 -07:00
Paul Berry 312b4ae52c Add/fix/cleanup type inference for throw and rethrow.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2954693002 .
2017-06-23 14:32:58 -07:00
Paul Berry 82561d8fa7 Avoid a crash if an initializing formal appears in the wrong context.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2947363003 .
2017-06-23 11:03:03 -07:00
Paul Berry 20c25f5cfc Small fixes to top level type inference.
This CL makes two fixes:

1. When a field is visited for the second time (to infer
subexpressions), don't use the inferred field type as the context;
this can change the inference results in a few rare circumstances,
making it different from what would be inferred inside a method body.

2. When doing extended top level type inference is enabled, only skip
subexpressions whose type is not needed.

Note that some tests had to be moved (either partially or completely)
into pkg/front_end/testcases/inference_new to reflect the fact that
front_end type inference now produces more correct results than
analyzer.  Also, the annotation comments in
pkg/front_end/testcases/inference_new/dependency_only_if_generic_method.dart
were completely bogus and needed to be changed.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2954063002 .
2017-06-23 10:47:58 -07:00
Paul Berry f09c561a06 Fix type inference of PropertySet when the receiver is a generic class.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2952883004 .
2017-06-23 10:41:47 -07:00
Paul Berry a9cf031831 Implement type inference for type literals
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2952313002 .
2017-06-23 10:35:52 -07:00
Paul Berry 6ac836fbb3 Make the kernel API for promoted type parameter bounds less error-prone.
I'm about to start introducing usages of TypeParameterType.bound, and
nearly all of the usage sites will need to fall back on
TypeParameter.bound if there is no bound stored in the
TypeParameterType.  This CL places the fallback behavior in the
TypeParameterType.bound getter so that we won't have to duplicate it
at every usage site (and risk making mistakes).  The few call sites
that don't want the fallback behavior (such as the one in
ast_to_binary.dart) can avoid it by referring to
TypeParameterType.promotedBound directly.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2952883003 .
2017-06-23 05:44:58 -07:00
Paul Berry 7b60c094d7 Implement type inference for conventional for-loops.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2951033004 .
2017-06-23 05:36:41 -07: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
Peter von der Ahé 94a44e0290 Refactor parseType in preparation for bigger changes.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2951463002 .
2017-06-22 12:47:53 +02:00
Paul Berry 945540c8bb Clean up duplicate type inference code for fetching parameter types.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2950193002 .
2017-06-21 14:57:43 -07:00
Paul Berry 95aaba5085 In strong mode, properly infer the return types of setters as void
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2952873002 .
2017-06-21 14:51:40 -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
Jens Johansen be9a3043aa [kernel] Make fasta call a new constructor on FallThroughError
On a switch fall through error, Fasta currently generates
```
throw new core::FallThroughError::•();
```

which generates the error-message via the VM:
```
'null': Switch case fall-through at line null.
```

This introduces a new constructor taking a url and a linenumber,
which then can give a better error message.

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2951453002 .
2017-06-21 08:40:59 +02:00
Paul Berry 5dd84a802e Only set types of conditional expressions in strong mode.
In spec mode the types aren't meaningful anyway (due to the fact that
the spec mode type system is unsound), and they don't match the
behavior of Rasta (causing bot failures).

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2953503002 .
2017-06-20 14:59:29 -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 eadfe2816b Record static types in the desugaring of null-aware property gets.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2946943002 .
2017-06-20 11:29:50 -07:00
Paul Berry d0f8a47f33 Rename "field" -> "accessor" in several type inference methods.
No functional change.  This just adjusts nomenclature to reflect the
fact that much of the type inference logic for dealing with fields
also applies to getters/setters.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2948773002 .
2017-06-20 10:34:27 -07:00
Dan Rubel d0910ce078 translate fasta parser error to analyzer error
* translate fasta parser BuiltInIdentifierAsType error to analyzer error
* remove unused error listener field

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2944383002 .
2017-06-20 13:18:48 -04:00
Dan Rubel 966d1a4701 integrating fasta parser
* start integrating fasta parser into analyzer
* extract new Scanner.fasta factory

R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2948473002 .
2017-06-20 12:24:13 -04: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 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
Konstantin Shcheglov f9af4e7ebe Refer the issue for making mixin transformation modular.
R=paulberry@google.com, sigmund@google.com
BUG=

Review-Url: https://codereview.chromium.org/2942253002 .
2017-06-16 10:21:55 -07:00
Paul Berry f5ea0a4403 Remove Kernel*Set classes.
These classes are no longer needed, since we use
KernelComplexAssignment (and derived classes) to represent
assignments.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2945553002 .
2017-06-16 06:57:51 -07:00
Jens Johansen 0a1583aa04 [kernel] Fix assert message.
This mimics the behaviour of the source-based pipeline,
i.e. instead of "manually" calling _AssertionError._create and giving
the correct parameters (wrong parameters, actually), use the helper
method _AssertionError.ThrowNew.

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

Review-Url: https://codereview.chromium.org/2940283002 .
2017-06-16 12:28:18 +02: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 cd1cd49f49 Remove an unnecessary null check
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2940843005 .
2017-06-15 20:44:36 -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 058c29f0a5 Only attempt to do type inference on fields that lack a declared type.
This avoids the need for KernelField._implicitlyTyped.

R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2941093002 .
2017-06-15 13:41:09 -07: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
Sigmund Cherem 5a63b0e339 Add flutter mode to patched_sdk
This is needed to create a platform.dill for flutter.

R=aam@google.com

Review-Url: https://codereview.chromium.org/2931773003 .
2017-06-14 17:29:36 -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
Peter von der Ahé 246334011a Ignore recoverable parser errors in outline_builder to avoid double reporting.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2940843003 .
2017-06-14 19:14:53 +02: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
Paul Berry 92a878f276 Fix argument names for handleIndexedExpression.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2935833002 .
2017-06-14 06:05:53 -07: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