Commit graph

1142 commits

Author SHA1 Message Date
Peter von der Ahé
643b54f7a9 Remove unneeded arguments.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2959023002 .
2017-06-28 10:10:00 +02:00
Peter von der Ahé
616da7ea04 Generate type variable events before parsing return type.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2963473004 .
2017-06-28 10:08:10 +02:00
Peter von der Ahé
97454851b8 Remove all type-related peeking.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2958073002 .
2017-06-28 10:07:21 +02:00
Peter von der Ahé
f10bdc6872 Reorganize parseType.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2961673003 .
2017-06-28 10:03:17 +02:00
Peter von der Ahé
90fb88710f Rename handleFunctionType to endFunctionType.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2961813002 .
2017-06-28 10:00:57 +02:00
Peter von der Ahé
08cfa29ec9 Use correct URI for field inference.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2955063003 .
2017-06-28 09:58:42 +02:00
Paul Berry
474d5e5d7f Test of type inference when super calls are unresolved.
See https://github.com/dart-lang/sdk/issues/30000 for an illustration
of why this is necessary.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2958113002 .
2017-06-27 14:10:05 -07:00
Paul Berry
12186bb40b Add a test to verify that variables declared in for-loops can be type promoted.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2960723003 .
2017-06-27 08:29:52 -07:00
Paul Berry
fc32e0e72b Remove hack from KernelTypePromoter.isPromotionCandidate.
All variable declarations encountered by type inference are now of
type KernelVariableDeclaration, so we no longer need a hack to handle
ordinary VariableDeclaration objects.

Removing the hack avoids covering up bugs.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2961723002 .
2017-06-27 06:00:01 -07:00
Paul Berry
2f7c6d61f5 Add type inference for break and continue statements.
Note that no actual type inference needs to be performed, but we still
need to implement the _inferStatement() methods so that we can get rid
of the hack in KernelTypeInferrer.inferStatement.  Also, we need to
call into the listener so that once this logic is hooked into
AstBuilder, analyzer will stay in sync with type inference.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2962583002 .
2017-06-26 14:51:07 -07:00
Paul Berry
93ab0f107e Implement type inference for symbol literals.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2958813002 .
2017-06-26 14:28:48 -07:00
Erik Corry
3c543bb210 Revert "VM: Reland Inline instance object hash code into object header on 64bit."
This reverts commit 8378b8fdbf due to
mysterious crashes on 32 bit ARM with the Flutter Gallery app.

R=aam@google.com
BUG=

Review-Url: https://codereview.chromium.org/2962543002 .
2017-06-26 23:06:09 +02:00
Paul Berry
d13f09c9e0 Add listener calls to ThisExpression and KernelTypeLiteral.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2961693002 .
2017-06-26 13:45:31 -07:00
Paul Berry
9f078625d4 Add type inference for super property gets.
I implemented the correct logic for both SuperPropertyGet and
DirectPropertyGet, since there are TODO comments in the code
indicating that the former will be replaced by the latter when
possible.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2959823002 .
2017-06-26 13:40:06 -07:00
Paul Berry
e24eab66d9 Add type inference for super method invocations.
I implemented the correct logic for both SuperMethodInvocation and
DirectMethodInvocation, since there are TODO comments in the code
indicating that the former will be replaced by the latter when
possible.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2954403002 .
2017-06-26 12:42:46 -07:00
Paul Berry
5cd3c2c8dc Add type inference for assert statements.
Note that since the first argument of an assert statement may be
either of type `bool` or `() -> bool`, and the second argument may be
any object, no type context is passed down in downward inference; the
only inference we need to do is to recursively invoke
`inferExpression` to ensure that subexpressions are inferred properly.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2959763002 .
2017-06-26 10:05:08 -07:00
Paul Berry
213c2080a5 Add type inference for while and do loops.
Analyzer does not type infer these constructs correctly (it uses an
empty context for the loop condition, instead of bool), so the tests
are in inference_new.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2954253002 .
2017-06-26 09:07:27 -07:00
Paul Berry
7553b2e75c Implement type inference for try/catch blocks.
Note that the types of the exception and stack trace variables are set
in the BodyBuilder since they do not depend on inference of other
parts of the function.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2954823002 .
2017-06-26 08:57:00 -07:00
Paul Berry
b94fdceadc Add type inference for switch statements.
Analyzer does not infer switch cases correctly (it uses an empty
context for the case expression, instead of the type of the switch
expression), so the tests are in inference_new.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2953423002 .
2017-06-26 08:49:01 -07:00
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
0c1dab2933 Re-introduce corrupted type inference tests.
These two tests were added some time ago, but they became corrupted
(presumably due to a formatter bug that has since been fixed).  Later,
I moved the corrupted tests into the inference_new folder because they
didn't infer correctly with analyzer.

This CL re-introduces the original uncorrupted tests so that we don't
lose test coverage.

Note that these tests make use of a syntax that Fasta doesn't support
yet, so they are marked as failing.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2958623002 .
2017-06-23 14:26:53 -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
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
Paul Berry
a7ab70eb06 Move tests {list,map}_literals_can_infer_null_top_level to inference_new
These tests' expectations reflect a drawback in analyzer's type
inference--it doesn't infer the correct types lists and maps
containing `null` when those structures occur outside a method body.
The new front_end type inference engine does the right thing.

Accordingly, we have to move the test to inference_new, so that we can
update its expectations without breaking analyzer's test code.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2951373002 .
2017-06-23 07:40:52 -07:00
Paul Berry
c4ecf098aa Move test infer_use_of_void to inference_new
This test's expectations reflect a drawback in analyzer's type
inference--it doesn't infer the correct types for calls to methods
returning `void` when those calls occur outside of a method body.  The
new front_end type inference engine does the right thing.

Accordingly, we have to move the test to inference_new, so that we can
update its expectations without breaking analyzer's test code.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2953903002 .
2017-06-23 07:33:50 -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
Peter von der Ahé
03aad06299 Add regression tests from Luke's bug reports. Part 2.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2959463003 .
2017-06-23 14:37:27 +02: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é
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
Erik Corry
8378b8fdbf VM: Reland Inline instance object hash code into object header on 64bit.
Inline instance object hash code into object header on 64 bit.

64 bit objects have 32 bits of free space in the header word.
This is used for the hash code in string objects. We take it
for the default hash code on all objects that don't override
the hashCode getter.

This is both faster and a memory reduction. Eg it makes the
MegaHashCode part of the Megamorphic benchmark 6 times faster.

This is a reland of https://codereview.chromium.org/2912863006/
It fixes issues with the 32 bit compare-swap instruction on
ARM64 and fixes a fragile tree shaking test that is sensitive
to which private methods are in the core libraries.

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

Review-Url: https://codereview.chromium.org/2954453002 .
2017-06-22 14:56:24 +02: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
e981c6fdbc Add tests of null-aware constructs in void contexts.
Fasta desugares some expressions differently in void contexts, so to
be on the safe side, we should test that null-aware invocations and
property accesses work in both void and non-void contexts.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2948843002 .
2017-06-20 15:12:01 -07: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
1594006758 Print static types of conditional expressions.
I want to start testing that Fasta sets the static types of
conditional expressions correctly, so I need Fasta's expectations
files to include them.

This CL just adds the static types to the printing logic in
ast_to_text.dart and updates expectations so that the tests continue
to pass.  I will make behavioral changes to Fasta in future CLs.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2949753002 .
2017-06-20 07:33:54 -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
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
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
b513e88de8 Fix infer_instance_accessor_ref test
The test contained a typo which caused `dynamic` to be inferred by
accident.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2945603002 .
2017-06-16 07:04:14 -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
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
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
Paul Berry
e03744a740 Fix fasta testcase to avoid a super call to an abstract method.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2941813002 .
2017-06-14 10:55:31 -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é
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é
14e9d0bd89 Prepare for improved error recovery from compile-time errors.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2931423002 .
2017-06-13 15:59:18 +02:00
Peter von der Ahé
11f82b12d2 Update golden files.
R=karlklose@google.com

Review-Url: https://codereview.chromium.org/2937683002 .
2017-06-13 10:46:04 +02:00
Peter von der Ahé
ea30fb6a0d Follow-up to CLs 2933723002 and 2932973003.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2933813002 .
2017-06-13 09:45:41 +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
Peter von der Ahé
a78250d931 Support metadata on local variables.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2936503002 .
2017-06-13 09:15:54 +02:00
Peter von der Ahé
092ef81f95 Complain about cyclic typedefs.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2931303002 .
2017-06-13 09:13:23 +02:00
Peter von der Ahé
8da7993d63 Attempt to instantiate an enum class is a compile-time error.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2935593002 .
2017-06-13 09:12:51 +02:00
Peter von der Ahé
f559a6d1e9 Throw NSM on unresolved factory redirection.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2933733002 .
2017-06-13 09:12:20 +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
31e2b4ac84 Add offsets to the == null calls inserted by null-aware desugaring.
This makes it possible to close a gap in testing instrumentation:
previously any annotations that were missing a file offset got
silently dropped.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2940453002 .
2017-06-12 14:06:51 -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
Dmitry Stefantsov
1c544012c3 Re-validate command line options after changing them in fasta
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2934763002 .
2017-06-12 11:30:42 +02:00
Peter von der Ahé
080a25f3a6 Various semantic checks on field initializers.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2929383002 .
2017-06-12 11:15:49 +02:00
Peter von der Ahé
2867303232 Various issues with duplicated names.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2934713002 .
2017-06-12 11:11:45 +02:00
Peter von der Ahé
0c7d657333 Complain about duplicated defer.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2933723002 .
2017-06-12 10:33:40 +02:00
Peter von der Ahé
35d77460e4 Various semantic checks regarding const and final.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2932973003 .
2017-06-12 10:27:22 +02: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é
202655ebb6 Add option for printing tokens produced by the scanner.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2933533002 .
2017-06-10 10:14:36 +02:00
Peter von der Ahé
96e494d534 Complain about external methods with a body.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2930093002 .
2017-06-10 10:13:04 +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
Peter von der Ahé
dcbac2be00 Complain about incorrect use of null-aware operations.
R=danrubel@google.com, johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2932723003 .
2017-06-10 10:11:36 +02:00
Peter von der Ahé
fd9716fa95 Various semantic checks on formal parameters.
R=danrubel@google.com

Review-Url: https://codereview.chromium.org/2926953004 .
2017-06-10 10:10:07 +02:00
Paul Berry
6b65fc22f7 Annotate targets of implicit this property gets/sets in inference tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2933663002 .
2017-06-09 17:41:13 -07:00
Paul Berry
8f5bcddc31 Implement type inference for assignments to a static variable.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2933643002 .
2017-06-09 17:36:20 -07:00
Paul Berry
ef94f715a9 Add type inference for assignment to local variables.
Also fix some upwards inference cases for assignment to index
expressions.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928033005 .
2017-06-09 15:13:14 -07:00
Konstantin Shcheglov
c2f18fc930 Implement promised watch behaviour.
1. There are no reasons to use different watch function between
   computeDelta() invocations, so I moved it to the constructor.

2. We need to call it, and await, before reading files, not after.

3. Added tests.

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

Review-Url: https://codereview.chromium.org/2931183003 .
2017-06-09 15:04:30 -07:00
Konstantin Shcheglov
6f4bba5f03 Compute API signatures of files.
Note, that in non-incemental case this change has negative performance
implications - compilation is 10% slower. Computing MD5 hashes is very
expensive.

In real life scenarios we will cache API signatures and URIs as
part of unlinked information for each file.

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

Review-Url: https://codereview.chromium.org/2926883003 .
2017-06-09 11:41:29 -07:00
Paul Berry
4abff2291b Rework type inference of assignments to index expressions.
The approach from the las CL (try to figure out the structure of the
assignment expression from the desugared result) turned out to be
unsustainably complex.  In this version we keep track of the structure
while doing the desugaring, and then store the result in a wrapper
object the kernel AST.  The wrapper object defers visit methods to the
object it wraps, so when the kernel objects are serialized to disk,
the wrapper disappears.

I also took the liberty of removing the code that inserts types
into the temporary variables and conditional expressions
introduced by desugaring.  I will add this in a later CL if it
proves to be necessary.

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

Review-Url: https://codereview.chromium.org/2927013004 .
2017-06-09 10:48:07 -07:00
Peter von der Ahé
d9f14d6a2b Add --sdk option.
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2929783002 .
2017-06-09 15:52:14 +02:00
Johnni Winther
2042128817 Include uriToSource from dill-based libraries in output.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2929103002 .
2017-06-09 14:11:43 +02:00
Dmitry Stefantsov
aa8ca9244a Add getTarget method to CompilerCommandLine
The method is used to create an instance of a backend target class.
CompilerCommandLine already has the necessary information for this ("target"
name string and "strongMode" flag).  Additionally, a backed target instance is
now not created in fasta.dart/parseScriptInFileSystem, but should be passed at
the call site.

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

Review-Url: https://codereview.chromium.org/2932513003 .
2017-06-09 11:04:44 +02:00
Konstantin Shcheglov
cf59b1a0f9 Remove ClassHierarchy factory constructor.
KernelTarget already uses IncrementalClassHierarchy, and other clients
either need ClosedWorldClassHierarchy, so should explicitly create it,
or don't care, and can be switched to IncrementalClassHierarchy.

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

Review-Url: https://codereview.chromium.org/2930973002 .
2017-06-08 18:42:22 -07:00
Dan Rubel
56402976cd more fixes for fasta analyzer integration
* fix scanner adapter setSourceStart
* fix fasta token copy() methods
* replace "is TokenWithComment" with "?.preceedingComments != null"
* update scanner test

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2928773003 .
2017-06-08 18:02:09 -04:00
Paul Berry
029771d746 Add type inference for complex assignments whose LHS is an index expression.
In later CLs I will expand on this code to handle other kinds of
complex assignments.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926763003 .
2017-06-08 09:25:24 -07:00
Peter von der Ahé
001ac97389 Implement initializer asserts.
Closes https://github.com/dart-lang/sdk/issues/29762

R=kasperl@google.com

Review-Url: https://codereview.chromium.org/2930673002 .
2017-06-08 13:46:26 +02:00
Sigmund Cherem
e551bef8ba add check of preconditions in run step.
BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2914773003 .
2017-06-07 15:45:55 -07:00
Sigmund Cherem
6e8155ae6f Follow up improvement for checking dart:_builtin
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2915153002 .
2017-06-07 15:38:18 -07:00
Sigmund Cherem
cb5f3842c4 Skip directly to the last library to set the entry point and check importUri
instead of fileUri.

On some scenarios fileUri is relative and entryUri was absolute, but importUri
should match for the entry library.

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926933002 .
2017-06-07 14:50:01 -07:00
Sigmund Cherem
aecfab68aa Add an incremental reloader example and a utility tool to trigger a reload by
hand.

The example includes:
 - an interactive UI that lets you trigger reloads without typing commands
 - a wrapper of the incremental kernel generator that invalidates files based on
 modification time stamps

BUG=
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928483005 .
2017-06-07 13:44:56 -07:00
Sigmund Cherem
ebdb0af64f Add integration test: hot reload + incremental compiler
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925953002 .
2017-06-07 12:47:27 -07:00
Konstantin Shcheglov
c510737b17 Make a copy of files to invalidate to avoid concurrent modifications.
In contrast to Analysis Driver, in Kernel Driver FileState.refresh()
is asynchronous, so we might (and actually do) get concurrent watch
events that update the set of invalidate files.

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

Review-Url: https://codereview.chromium.org/2924943005 .
2017-06-07 11:10:50 -07:00
Konstantin Shcheglov
400c7a0cb5 Set main procedure for Program.
Why is it called main _method_ when it is actually Procedure?

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

Review-Url: https://codereview.chromium.org/2931603003 .
2017-06-07 10:59:32 -07:00
Konstantin Shcheglov
710af5af38 Measure time spent building graph of files.
It's about 1000 ms for analyzer_cli, which I use for benchmarking.

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

Review-Url: https://codereview.chromium.org/2932463002 .
2017-06-07 10:26:09 -07:00
Paul Berry
5c3dd4b11b Change MethodInvocation.interfaceTarget from a Procedure to a Member.
It's possible for the interface target to be a field, e.g.:

    typedef void F();
    class C {
      F f;
    }
    void g(C c) {
      c.f(); // Interface target is C::f
    }

Also, this CL fixes MethodInvocation.getStaticType() in the case where
the interface target is a getter.

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

Review-Url: https://codereview.chromium.org/2923653003 .
2017-06-07 09:20:53 -07:00
Konstantin Shcheglov
c569a4a8b8 Compute all canonical names only for libraries being serialized.
This makes compilation with Kernel Driver about 20% faster than Fasta,
about 5.8 seconds using Kernel Driver vs. 7.2 seconds using Fasta. Note
that this is initial compilation, i.e. nothing read from the cache yet.

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

Review-Url: https://codereview.chromium.org/2927463003 .
2017-06-07 08:50:04 -07:00
Dan Rubel
b0374f214c update analyzer parser tests for fasta scanner
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2930453002 .
2017-06-07 11:05:44 -04:00
Peter von der Ahé
c4a8b146e0 Semantic checks on switch cases and fall-through errors.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2926533004 .
2017-06-07 11:26:34 +02:00
Peter von der Ahé
d6a766bb14 Improve NSM handling.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2927613002 .
2017-06-07 09:28:13 +02:00
Paul Berry
b18c325f68 Add int.toString() to analyzer mock SDK.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2922383003 .
2017-06-06 13:35:36 -07:00
Paul Berry
49110ba0d6 Fix implementation of fold() in analyzer's mock SDK.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2924853003 .
2017-06-06 13:23:45 -07:00
Paul Berry
7ab22d7ad2 Properly flatten FutureOr types when inferring the type of an async method.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2923733004 .
2017-06-06 13:13:08 -07:00
Paul Berry
f7f9d1766f Fix corner cases of type inference with implicit references to .call.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2928613003 .
2017-06-06 13:00:26 -07:00
Konstantin Shcheglov
a0fb4d9aef Replace ClosedWorldClassHierarchy with IncrementalClassHierarchy in SourceLoader.
This does not cause any measurable performance changes for Fasta.

This speeds up initial compilation using Kernel Driver from 16 seconds
to about 7.6 seconds. Just using Fasta takes 7 seconds, so Kernel
Driver is just about 10% slower now.

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

Review-Url: https://codereview.chromium.org/2927523002 .
2017-06-06 12:38:23 -07:00
Paul Berry
32e78868bd Record method invocation targets that are not procedures.
We don't yet store the targets in the kernel representation, since
kernel currently requires method invocation targets to be procedures
(see https://codereview.chromium.org/2923653003/).  But we record the
target that we *would* store in the kernel to instrumentation so that
we can pass tests.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2920223008 .
2017-06-06 12:27:34 -07:00
Peter von der Ahé
470127ae46 Setup correct scope for initializers and complain about fields initialized more than once.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2916333002 .
2017-06-06 19:35:35 +02:00
Paul Berry
47d50e51a3 Add type inference for this expressions.
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2925603002 .
2017-06-06 09:54:19 -07:00
Peter von der Ahé
7df768af0d Restore invariant that stack is empty in parseFunctionBody.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2914373002 .
2017-06-06 16:58:31 +02:00
Dmitry Stefantsov
09e755196a Pass a Target instance to DillTarget instead of its name
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2924833002 .
2017-06-06 16:03:49 +02:00
Dan Rubel
c36936f37f translate remaining fasta scanner error codes
This updates the fasta scanner to translate the remaining
previously untranslated error codes so that they will be seen
by the analyzer when the fasta scanner is used by analyzer.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2923113002 .
2017-06-06 09:08:13 -04:00
Paul Berry
b5883633f7 Do not annotate type parameters of instantiated function types.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925693002 .
2017-06-05 13:26:12 -07:00
Paul Berry
2513c2b93f Adjust expectations for parameterized closures to match front_end behavior.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2925583003 .
2017-06-05 12:51:37 -07:00
Paul Berry
2162b2da9b Improve annotation of type variables in type inference tests.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2918373003 .
2017-06-05 11:47:07 -07:00
Paul Berry
3285dcf039 Remove type parameters from type promotion classes.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2923613002 .
2017-06-05 11:42:10 -07:00
Dan Rubel
32677b631f option to enable fasta scanner
* add cmdline option so that analyzer will use the fasta scanner
* refactor handling of unterminated strings

Use -DuseFastaScanner=true to use the fasta scanner
rather than the analyzer scanner

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2919163002 .
2017-06-05 14:13:08 -04:00
Paul Berry
416a860de5 Mark some more type inference tests as passing.
These tests were already working--they just needed expectations files
(and in one case, a `main` method).

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2926433002 .
2017-06-05 10:07:27 -07:00
Dan Rubel
c4449efa33 improve handling of missing interpolation identifier
When the fasta scanner finds a STRING_INTERPOLATION_IDENTIFIER token '$'
without an identifier, it now inserts a synthetic identifier

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

Review-Url: https://codereview.chromium.org/2922563002 .
2017-06-02 15:16:44 -04:00
Dan Rubel
5b6d7653fe fix unterminated interpolation expression handling
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2914213003 .
2017-06-02 13:47:08 -04:00
Paul Berry
506389a744 Remove an unnecessary TODO from PropertyGet type inference.
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2921913002 .
2017-06-02 08:57:48 -07:00
Dan Rubel
b61f9f2343 improve fasta unterminated string recovery
This updates the fasta scanner
to append synthetic closing quotes to unterminated strings.

Rework of https://codereview.chromium.org/2912693002/

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

Review-Url: https://codereview.chromium.org/2915093002 .
2017-06-02 11:51:11 -04:00
Dmitry Stefantsov
1e2f06f8da Reapply "Use backend targets to run Kernel transformations in Fasta"
This reverts commit 0b424ca5d2

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2919003003 .
2017-06-02 16:10:28 +02:00
Peter von der Ahé
a79a59d19c Improve position information.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2915123002 .
2017-06-02 15:14:53 +02:00
Peter von der Ahé
cbcb7d4885 Clean up handling of types.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2915933004 .
2017-06-02 14:53:20 +02:00
Peter von der Ahé
0db20bf56a Add testing configuration for Fasta.
R=dmitryas@google.com

Review-Url: https://codereview.chromium.org/2919043002 .
2017-06-02 14:29:43 +02:00
Peter von der Ahé
696f00d96b Implement library access restrictions and privacy.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2916863003 .
2017-06-02 13:13:38 +02:00
Dmitry Stefantsov
0b424ca5d2 Revert "Use backend targets to run Kernel transformations in Fasta"
This reverts commit 8ff762067a.

TBR=ahe@google.com

Review-Url: https://codereview.chromium.org/2918923003 .
2017-06-02 12:45:34 +02:00
Dmitry Stefantsov
ece423de17 Revert "Use 'outline.dill' instead of 'platform.dill' in kernel isolate"
This reverts commit 303ab0aa96.

TBR=sigmund@google.com

Review-Url: https://codereview.chromium.org/2919003002 .
2017-06-02 12:18:54 +02:00
Dmitry Stefantsov
303ab0aa96 Use 'outline.dill' instead of 'platform.dill' in kernel isolate
R=ahe@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2916083002 .
2017-06-02 10:53:40 +02:00
Dmitry Stefantsov
8ff762067a Use backend targets to run Kernel transformations in Fasta
R=ahe@google.com, scheglov@google.com

Review-Url: https://codereview.chromium.org/2918623004 .
2017-06-02 10:40:13 +02:00
Paul Berry
eefdf15aa1 Perform type inference on default values of optional/named parameters.
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2915763008 .
2017-06-01 21:18:37 -07:00
Paul Berry
3babf830e7 Remove remaining references to defunct parameter --failure-summary.
As of db06324975, this parameter is no
longer supported by the test framework.

R=ahe@google.com

Review-Url: https://codereview.chromium.org/2915933005 .
2017-06-01 21:13:14 -07:00
Paul Berry
8ae9237efd Clean up type inference for PropertySet.
These changes are follow ups to
cd5bacbc54.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2916273002 .
2017-06-01 20:56:43 -07:00
Paul Berry
da869cff4e Fix inference test annotation of named/optional parameters in function types.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2915913004 .
2017-06-01 20:51:29 -07:00
Paul Berry
d17f3f3bbd Annotate optional parameter inferred types in front end test cases.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2921533004 .
2017-06-01 20:45:51 -07:00
Paul Berry
349f95f687 Fix a corner case of block closure inference.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2914983003 .
2017-06-01 16:07:59 -07:00
Paul Berry
eec5e74188 Normalize URIs on entry to ValidatingInstrumentation.
This makes it possible to remove a type inferrer hack that wouldn't
have worked properly with part files.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2921683002 .
2017-06-01 09:54:56 -07:00
Konstantin Shcheglov
5bdfd1e69b Pass ClassHierarchy instead of creating it.
MixinFullResolution is also updated to create new ClassHierarchy
instance only if there are transformed classes. This improves
incremental kernel generator initial time from 22 to 16 seconds.

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

Review-Url: https://codereview.chromium.org/2918593003 .
2017-06-01 07:20:13 -07:00
Peter von der Ahé
5b94cfe33a Various infrastructure changes.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2917863003 .
2017-06-01 15:16:18 +02:00
Peter von der Ahé
984b13052d Compute correct return type for factory methods.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2917853002 .
2017-06-01 14:02:05 +02:00
Peter von der Ahé
679cd68453 Update expectations files.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2921623002 .
2017-06-01 14:01:12 +02:00
Paul Berry
7cdf85da06 Fix a corner case of function type inference.
When an expression function's expression has type `dynamic` (or
`Null`, since `Null` is coerced to `dynamic`), the inferred return
type is taken from the context.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2921583002 .
2017-05-31 21:26:14 -07:00
Sigmund Cherem
2046d08c09 Fix error recovery for extracting native name.
I discovered this now that native is
enabled more widely (see bot failures here:
https://build.chromium.org/p/client.dart/builders/vm-kernel-linux-release-x64-be/builds/2731/steps/vm%20tests/logs/stdio)

Here is an example input that hit the problem:

  K() sync* {}; // //# 50: compile-time error

TBR=ahe@google.com

Review-Url: https://codereview.chromium.org/2916773002 .
2017-05-31 16:17:15 -07:00
Paul Berry
a122a6409e Add some top level type inference rules for property gets.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2914113002 .
2017-05-31 15:17:16 -07:00
Paul Berry
cd5bacbc54 Implement type inference for PropertySet.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2919623002 .
2017-05-31 15:09:28 -07:00
Sigmund Cherem
922326a91f Fix performance regression for checking that retricted types are not
extended/implemented.

BUG=
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2907333003 .
2017-05-31 14:07:17 -07:00
Sigmund Cherem
682011c7b2 Move enableNative to target, turn it on by default
R=ahe@google.com

Review-Url: https://codereview.chromium.org/2913013003 .
2017-05-31 13:55:55 -07:00
Paul Berry
f9c1cab33b Remove some bogus type promotion code.
This code was part of an attempt to prototype some possible extensions
to type promotion to handle `if (x is! Foo)`.  I thought I had
rendered it harmless, but it was having some buggy effects.

Also added a test case demonstrating the problem.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2914093002 .
2017-05-31 13:40:33 -07:00
Paul Berry
26c61e4d22 Implement type inference for PropertyGet.
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2921443002 .
2017-05-31 12:26:10 -07:00