Commit Graph

67 Commits

Author SHA1 Message Date
Dmitry Stefantsov d59745029a [fasta] Update expectation files after CL 50945
Change-Id: I639fe81e848bec4a3d8735f55750d59eb422763d
Reviewed-on: https://dart-review.googlesource.com/54246
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-05-17 14:27:46 +00:00
Kevin Millikin 8dbe716085 Remove the unused GenericCovariantInterface bit
None of the back ends are using it and it imposes a cost to have to
compute it and try to preserve it.

Change-Id: I217e1191b535829021fa11f2698cadd8d4baf1c8
Reviewed-on: https://dart-review.googlesource.com/54383
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-05-09 15:04:43 +00:00
Dmitry Stefantsov 4f586e265e [fasta] Update expectation files after CL 50941
Change-Id: I85aba2501a7b8a911e122f0a802dfc21b7e87e1e
Reviewed-on: https://dart-review.googlesource.com/51620
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-05-08 10:53:47 +00:00
Kevin Millikin 9371ca061c Remove all the contravariance bits
Change-Id: Ib43b32d12749ddac0a93795cb5e8543eb5131dd9
Reviewed-on: https://dart-review.googlesource.com/52867
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-05-01 10:56:11 +00:00
Peter von der Ahé 1e312819ca Ensure errors guard erroneous expressions.
This changes wrapInCompileTimeError so we are certain that
compile-time errors are reported before the erroneous nodes.

We want to preserve erroneous nodes as, long term, this should help
with code completion.

Also introduce a located version as my next CL I'll have slightly
more accurate locations.

Change-Id: Id83d4b7a7d4fe260916816d72fac331251bad948
Reviewed-on: https://dart-review.googlesource.com/50422
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-04-12 14:51:19 +00:00
Kevin Millikin 74cf86cbbb Remove Kernel's DispatchCategory
It complicates the intermediate language, none of the back ends are
using it, and it's not something that we want transformation writers
and code generators to deal with.

Change-Id: Ic79f7935dd8619bd233346bb25947e864f38a104
Reviewed-on: https://dart-review.googlesource.com/50440
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-04-11 07:43:41 +00:00
Samir Jindel 4289a9967b Check expected outputs of transforms.
Change-Id: I56ff4d4391b7a22d709dc60b696646895928e34c
Reviewed-on: https://dart-review.googlesource.com/46100
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-03-15 12:11:13 +00:00
Paul Berry 424ae0f5e4 Check contravariance of property gets that resolve to fields.
Fixes #32501

Change-Id: Ic3c5aca1d12b73e40e63c6cdd8304b95f54e5497
Reviewed-on: https://dart-review.googlesource.com/46002
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-03-13 10:37:09 +00:00
Paul Berry 0d42430ed8 Change the implicit tear-off of call methods to be null-aware.
We want the implicit tear-off of a `call` method to succeed even if
the value is `null`, so we need the implicit tear-off to be equivalent
to `?.call`.

Change-Id: I5134858b84e501081a52d59b78b101597bdfcc4a
Reviewed-on: https://dart-review.googlesource.com/43480
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-27 09:44:27 +00:00
Peter von der Ahé d359ce8650 Replace \n in expectation files with newline
Change-Id: Ia8444f7b817ac8e298c4f212f7aaa4fc6ba026b7
Reviewed-on: https://dart-review.googlesource.com/42682
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2018-02-21 17:02:07 +00:00
Paul Berry c4de71ede2 Re-land "Change front_end handling of callable classes."
Original description:
Change front_end handling of callable classes.

This CL is the first in a series of CLs to change the handling of
callable classes in Dart 2.0.

For purposes of this description, a "callable class" is a class whose
interface contains a `.call` method.

In Dart 1.0, a callable class was considered to be a subtype of the
`.call` method's function type.  This allowed the user to create
custom objects with similar behavior to closures, but with additional
fields and methods.

In Dart 2.0, a callable class is just an ordinary class, with no
subtype relation to any particular function type.  (Note however that
it is still permissible for a class to declare that it "implements
Function").

To reduce the amount of code broken by this change, a piece of
syntactic sugar is being added: if an expression whose static type is
a callable class appears where a function type is expected, an
implicit tear-off of the `.call` method is inserted.

Note that it is still possible at compile time to invoke an expression
whose static type is a callable class, and it is still possible at
runtime to invoke an expression whose runtime type is a callable
class; in both cases, this is considered an implicit invocation of the
class's `.call` method.  This is unchanged from Dart 1.0 behavior.

This CL introduces test cases for the new behavior, and implements the
implicit tear-off of `.call` in the front end.

Still to be implemented in future CLs:

- Spec text needs to be written.

- DDC/analyzer code needs to be written to perform implicit tear-offs
  of `.call`.

- The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
  be changed so that callable classes are no longer considered
  subtypes of any particular function type.

- A small corner case involving type parameters still needs to be
  addressed (see TODO in
  pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).

Fixes #32064.

Change-Id: I0d397c608321e25ba42cc02aa8a516aa77aa7c9d
Reviewed-on: https://dart-review.googlesource.com/41280
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-14 15:22:25 +00:00
Paul Berry e2bdbb8bb8 Revert "Change front_end handling of callable classes."
This reverts commit f0a6330db0.

Reason for revert: Broken bots

Original change's description:
> Change front_end handling of callable classes.
> 
> This CL is the first in a series of CLs to change the handling of
> callable classes in Dart 2.0.
> 
> For purposes of this description, a "callable class" is a class whose
> interface contains a `.call` method.
> 
> In Dart 1.0, a callable class was considered to be a subtype of the
> `.call` method's function type.  This allowed the user to create
> custom objects with similar behavior to closures, but with additional
> fields and methods.
> 
> In Dart 2.0, a callable class is just an ordinary class, with no
> subtype relation to any particular function type.  (Note however that
> it is still permissible for a class to declare that it "implements
> Function").
> 
> To reduce the amount of code broken by this change, a piece of
> syntactic sugar is being added: if an expression whose static type is
> a callable class appears where a function type is expected, an
> implicit tear-off of the `.call` method is inserted.
> 
> Note that it is still possible at compile time to invoke an expression
> whose static type is a callable class, and it is still possible at
> runtime to invoke an expression whose runtime type is a callable
> class; in both cases, this is considered an implicit invocation of the
> class's `.call` method.  This is unchanged from Dart 1.0 behavior.
> 
> This CL introduces test cases for the new behavior, and implements the
> implicit tear-off of `.call` in the front end.
> 
> Still to be implemented in future CLs:
> 
> - Spec text needs to be written.
> 
> - DDC/analyzer code needs to be written to perform implicit tear-offs
>   of `.call`.
> 
> - The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
>   be changed so that callable classes are no longer considered
>   subtypes of any particular function type.
> 
> - A small corner case involving type parameters still needs to be
>   addressed (see TODO in
>   pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).
> 
> Fixes #32064.
> 
> Change-Id: I6a86491047ae467a5e767cb3cc7cecb570b29308
> Reviewed-on: https://dart-review.googlesource.com/40508
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Kevin Millikin <kmillikin@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>
> Reviewed-by: Erik Ernst <eernst@google.com>

TBR=paulberry@google.com,lrn@google.com,leafp@google.com,dmitryas@google.com,eernst@google.com,kmillikin@google.com

Change-Id: Ia3d3a6e46ceee2b2c55938bec95d09d50bbf06a7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/41240
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-14 13:10:54 +00:00
Paul Berry f0a6330db0 Change front_end handling of callable classes.
This CL is the first in a series of CLs to change the handling of
callable classes in Dart 2.0.

For purposes of this description, a "callable class" is a class whose
interface contains a `.call` method.

In Dart 1.0, a callable class was considered to be a subtype of the
`.call` method's function type.  This allowed the user to create
custom objects with similar behavior to closures, but with additional
fields and methods.

In Dart 2.0, a callable class is just an ordinary class, with no
subtype relation to any particular function type.  (Note however that
it is still permissible for a class to declare that it "implements
Function").

To reduce the amount of code broken by this change, a piece of
syntactic sugar is being added: if an expression whose static type is
a callable class appears where a function type is expected, an
implicit tear-off of the `.call` method is inserted.

Note that it is still possible at compile time to invoke an expression
whose static type is a callable class, and it is still possible at
runtime to invoke an expression whose runtime type is a callable
class; in both cases, this is considered an implicit invocation of the
class's `.call` method.  This is unchanged from Dart 1.0 behavior.

This CL introduces test cases for the new behavior, and implements the
implicit tear-off of `.call` in the front end.

Still to be implemented in future CLs:

- Spec text needs to be written.

- DDC/analyzer code needs to be written to perform implicit tear-offs
  of `.call`.

- The subtyping algorithm in DDC, analyzer, VM, and dart2js needs to
  be changed so that callable classes are no longer considered
  subtypes of any particular function type.

- A small corner case involving type parameters still needs to be
  addressed (see TODO in
  pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart).

Fixes #32064.

Change-Id: I6a86491047ae467a5e767cb3cc7cecb570b29308
Reviewed-on: https://dart-review.googlesource.com/40508
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2018-02-14 11:03:32 +00:00
Jens Johansen 6fe7b74e47 [kernel] Mark synthetic constructors as such
Fixes #31143

Change-Id: I2c844e48c955234de1b03de08c12729f72db4f3a
Reviewed-on: https://dart-review.googlesource.com/35921
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-01-19 12:29:56 +00:00
Jens Johansen c1160d8cfa [kernel] Change ast to text output to use synthetic instead of default
Change-Id: Ied8777df13aa0411daf89f3ad3ec6bdda7bb4898
Reviewed-on: https://dart-review.googlesource.com/35862
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-01-19 09:58:46 +00:00
Kevin Millikin 6fa813d818 Change handling of Kernel static errors
Before: Kernel static errors were represented by throwing a distinguished
error or else by calling a distinguished library const constructor.

Now: Kernel static errors are represented by InvalidExpression.  To support
error reporting, InvalidExpression has an optional message and a file
offset.  A back end can choose to signal these errors at any time; for
example, when deserializing the binary, or when compiling the procedure
containing the static error, or when the erroneous expression is evaluated
at run time.

InvalidStatement is removed because it can be encoded as ExpressionStatement
of InvalidExpression.

Future work:

* supporting static errors where an expression cannot appear in the AST
* allowing InvalidExpression to contain an Expression for error recovery
* adding a top-level list of static errors and warnings to the binary

Bug: https://github.com/dart-lang/sdk/issues/29840
Change-Id: Ifdfe9a76cee6cefed28061bf245be70531d2f413
Reviewed-on: https://dart-review.googlesource.com/31320
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-01-04 11:00:25 +00:00
Paul Berry d35f6c79cd Set PropertySet.dispatchCategory.
Fixes #31437.

Change-Id: I9ba84f8a3660e6bbd4dd86761b8f03cd3b414c00
Reviewed-on: https://dart-review.googlesource.com/27086
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-12-07 17:24:39 +00:00
Paul Berry c800a1cc29 Fix error recovery for invalid assignment.
Previously, the front end recovered from an invalid assignment by
producing an "as" expression, e.g.:

    int x;
    String y;
    x = y;

Would produce an "invalid assignment" error, as well as this kernel
code:

    int x;
    String y;
    x = y as{TypeError} int;

The rationale was that the "as" check was guaranteed to fail, so this
code would produce a runtime error at the correct location.  However,
there were two problems:

1. (Minor problem) the "as" doesn't actually fail if the RHS is null.

2. (Major problem) for type inference, the type of an assignment
expression is defined to be the type of the RHS.  This means that if
the invalid assignment gets used for type inference, we generate
mal-typed kernel code, e.g.:

    int x;
    String y;
    var z = (x = y);

Gets compiled to:

    int x;
    String y;
    String z = (x = y as{TypeError} int);

This CL addresses both problems by changing the kernel representation
so that it evaluates the RHS and then throws an exception.  Since a
"throw" expression has type Bottom, the kernel representation is
guaranteed to be properly typed.  This also ensures that an exception
gets thrown if the RHS is null.  Finally, as a side bonus, it makes
the error-recovered kernel code more similar to the kernel code we
generate in other error recovery scenarios.

Change-Id: Iac74e0c726ce029ac0560d271413e85c15bfec5c
Reviewed-on: https://dart-review.googlesource.com/24140
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-12-04 14:38:04 +00:00
Samir Jindel bf797e6507 [kernel] Re-land assert initializers.
This change updates Dart2js and DDC.
Thanks to johnniwinther@ for the Dart2js updates.

The original revision is in patchset 2.

Change-Id: I26db33312f003f88ccccb67b27998ef21a1f667f
Reviewed-on: https://dart-review.googlesource.com/25820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2017-12-04 11:22:34 +00:00
Paul Berry 7d65fec76e Reland "Route all messages through Loader."
This is the same as https://dart-review.googlesource.com/24481, but
with additional status file fixes.

Change-Id: Ic076c4dbf9c07e0fdf316298ca1ee1b6ce25002b
Reviewed-on: https://dart-review.googlesource.com/25508
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-12-01 22:47:06 +00:00
Ryan Macnak a646f51a5b Revert "Route all messages through Loader."
This reverts commit 8e4b0bda23.

Reason for revert: Failures on most kernel bots

Original change's description:
> Route all messages through Loader.
> 
> This ensures that all messages are passed to instrumentation.
> 
> Issues addressed in this CL:
> 
> * When I added addCompileTimeError, I forgot to remove addError.
> 
> * All messages now all arrive in a single location (Loader). SourceLoader adds instrumentation by overriding recordMessage.
> 
> * As I changed the type inferrer to use addCompileTimeError, I broke DDC. This is because the front_end API (generateKernelInternal in kernel_generator_impl.dart) returns null if there are any errors reported via addCompileTimeError (and this didn't happen with addError, that shouldn't have been there anyways).
> 
> * Due to the previous problem, I changed generateKernelInternal to ignore errors, but then I started getting missing compile-time errors. This turned out to be due to the the silent parameter used during outline- and diet-parsing.
> 
> * I've removed all the "silent" parameters. This didn't work reliably and have been confusing Brian, Dan, and me several times when making parser changes. Instead we detect duplicated messages and avoid reporting them more than once.
> 
> * Types in error messages got names that where using a global object (globalDebuggingNames in pkg/kernel/lib/text/ast_to_text.dart). This meant that the #lib prefix would vary depending on how many tests were run which affected the serialized error message in pkg/front_end/testcases/invalid_assignment.dart.strong.expect.
> 
> Change-Id: I3d89372d6593a6e7e50cce733f61eedb881e15ed
> Reviewed-on: https://dart-review.googlesource.com/24481
> Commit-Queue: Peter von der Ahé <ahe@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>
> Reviewed-by: Kevin Millikin <kmillikin@google.com>

TBR=paulberry@google.com,ahe@google.com,kmillikin@google.com

Change-Id: I9f7b345a8ff040fc7aa73c5cb605190e47fd284b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/25660
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-12-01 20:37:45 +00:00
Samir Jindel 48a927acb2 Revert "[kernel] Introduce assert initializers."
Reverting due to several test failures.

This reverts commit 67adfe741b.

Bug:
Change-Id: Idd1aa15d47df68f2938285468dfa3d5043d8dae2
Reviewed-on: https://dart-review.googlesource.com/25520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-12-01 17:46:05 +00:00
Samir Jindel 67adfe741b [kernel] Introduce assert initializers.
Assert initializers in Dart may be compiled directly to this form of initializer,
rather than through local initializers as is done now.

Bug:
Change-Id: Ia149ea3d1df5d1dc18be5636801604ffaf7ca7d8
Reviewed-on: https://dart-review.googlesource.com/14760
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-01 14:04:06 +00:00
Peter von der Ahé 8e4b0bda23 Route all messages through Loader.
This ensures that all messages are passed to instrumentation.

Issues addressed in this CL:

* When I added addCompileTimeError, I forgot to remove addError.

* All messages now all arrive in a single location (Loader). SourceLoader adds instrumentation by overriding recordMessage.

* As I changed the type inferrer to use addCompileTimeError, I broke DDC. This is because the front_end API (generateKernelInternal in kernel_generator_impl.dart) returns null if there are any errors reported via addCompileTimeError (and this didn't happen with addError, that shouldn't have been there anyways).

* Due to the previous problem, I changed generateKernelInternal to ignore errors, but then I started getting missing compile-time errors. This turned out to be due to the the silent parameter used during outline- and diet-parsing.

* I've removed all the "silent" parameters. This didn't work reliably and have been confusing Brian, Dan, and me several times when making parser changes. Instead we detect duplicated messages and avoid reporting them more than once.

* Types in error messages got names that where using a global object (globalDebuggingNames in pkg/kernel/lib/text/ast_to_text.dart). This meant that the #lib prefix would vary depending on how many tests were run which affected the serialized error message in pkg/front_end/testcases/invalid_assignment.dart.strong.expect.

Change-Id: I3d89372d6593a6e7e50cce733f61eedb881e15ed
Reviewed-on: https://dart-review.googlesource.com/24481
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2017-12-01 11:38:26 +00:00
Paul Berry 0eefa06d14 Insert implicit downcasts for the conditions of while statements.
Change-Id: Ieb1bc13de5afb16e75ab810de35002bb3b966ea8
Reviewed-on: https://dart-review.googlesource.com/23742
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-27 17:07:41 +00:00
Paul Berry b47ef6bdeb Insert implicit downcasts for the conditions of assert statements.
Tests that have begun failing due to this change are marked with a
reference to issue #31402.

Change-Id: Ife1531ee029dda32e91f7aa0d5720353de7996d5
Reviewed-on: https://dart-review.googlesource.com/23726
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-11-26 17:06:00 +00:00
Paul Berry 5ce5811216 Insert implicit downcasts for the conditions of for statements.
Change-Id: I213617cb4ea1a5c29f8a6a56f54792c59cc4e132
Reviewed-on: https://dart-review.googlesource.com/23221
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-23 16:47:32 +00:00
Paul Berry b7a0db69a6 Fix compile-time error in implicit_downcast_not.dart test case
Change-Id: Icf58ba984fadd27580dc37c901532dcdbf101a99
Reviewed-on: https://dart-review.googlesource.com/23146
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-23 16:39:47 +00:00
Paul Berry 9255de668e Insert implicit downcasts for constructor initializer expressions.
Change-Id: Ic258db9c353a4a0ab33a96c3847b174937fcf9e5
Reviewed-on: https://dart-review.googlesource.com/23220
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-23 16:39:28 +00:00
Paul Berry 501872471c Insert implicit downcasts for the conditions of do statements.
Change-Id: I8bfffa0796775434cea767ec9ad13cf5697812d2
Reviewed-on: https://dart-review.googlesource.com/23140
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-11-22 21:47:14 +00:00
Paul Berry 245340dd7f Insert implicit downcasts for the conditions of if statements.
Change-Id: I788d50dc3d95bb4652ff122a993cd092d7262c31
Reviewed-on: https://dart-review.googlesource.com/23160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-11-22 19:29:24 +00:00
Paul Berry 6786f1944a Insert implicit downcasts for the operands of "not" expressions.
Tests that have begun failing due to this change are marked with a
reference to issue #31402.

Change-Id: I3d29a1058af5ba43bc2868d85de1e9d87b666ee2
Reviewed-on: https://dart-review.googlesource.com/23080
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-11-22 17:55:27 +00:00
Paul Berry 8cdd9d323c Insert implicit downcast checks for invocation arguments.
Tests that have begun failing due to this change are marked with a
reference to issue #31402.

Change-Id: I1fa7490f6143bd6ceca80f831e0196b16c497966
Reviewed-on: https://dart-review.googlesource.com/20907
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-11-21 00:17:37 +00:00
Paul Berry fa7296a25e Add annotations to testcases for contravariance.
Change-Id: I1ce20f30948af8ff3de304ace036cbcf914861c9
Reviewed-on: https://dart-review.googlesource.com/16380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-24 22:13:28 +00:00
Kevin Millikin 034501e805 Handle forwarding stubs in mixin application classes
Before: mixin application classes could not have methods of their
own.

After: type inference will sometimes insert forwarding stubs in mixin
application classes.  In the mixin elimination transformation, these
forwarding stubs are replaced with the methods of the mixin class if
they have the same name, but the parameter flags from the forwarding
stub are retained.  The other forwarding stubs are left as methods of
the class.
Change-Id: I5ee89d6b1fc83194df82009c2800b54ce856e8c5
Reviewed-on: https://dart-review.googlesource.com/15887
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2017-10-24 08:04:18 +00:00
Paul Berry 9aa3a0eec0 Desugar a method invocation into a getter/call when necessary to add an "as" check.
Change-Id: Ic0754a9cfa80a1a91f7c421fb5a1cd55e63e1534
Reviewed-on: https://dart-review.googlesource.com/15762
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-21 11:59:43 +00:00
Paul Berry b8f81c45a5 Standardize on calling synthetic setter parameters '_'.
This has no effect on the generated kernel output; it just affects tests.

Also fix an incorrect type in field_forwarding_stub_explicit_covariant.dart.

Change-Id: Ic89d59a52648dc37a43cb12c4289611daaf422c6
Reviewed-on: https://dart-review.googlesource.com/15647
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-20 19:41:28 +00:00
Paul Berry 270e4c186d Add "as" checks to getter invocations when needed due to return type contravariance.
Change-Id: Ib0151e7f19021c87a08198580dcc6d56425882af
Reviewed-on: https://dart-review.googlesource.com/15221
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-19 19:08:28 +00:00
Paul Berry ca0933c487 Add the appropriate "as" nodes when needed due to return type contravariance.
Also add a test to verify that contravariance is properly handled for
method calls using "if-null" syntax (since this is handled by a
slightly different code path in the front end).

Change-Id: I93ee8b38ff39d78e25cac23ff048fcf69f15b5db
Reviewed-on: https://dart-review.googlesource.com/15000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-19 16:13:26 +00:00
Paul Berry b51d5035aa Annotate getter accesses with @callKind.
Change-Id: I56453f2824776f4d63de58a09f8ecc5b6f2df8ad
Reviewed-on: https://dart-review.googlesource.com/14622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-18 17:51:07 +00:00
Paul Berry c2d1260c4a Annotate procedures with contravariant return types.
This will allow the front end to efficiently decide where to insert
"as" checks.

Change-Id: I4776488684acdbf356ed3cb286e8d516d18719e1
Reviewed-on: https://dart-review.googlesource.com/14507
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-17 20:20:40 +00:00
Paul Berry 078da9f5c0 Exchange the order of looping in _computeCovarianceFixes.
The outer loops are now through the arguments of the method to be
fixed, and the inner loops are through the inherited methods.  This
allows us to handle the situation where a forwarding stub is needed
because isGenericCovariantInterface changes from true to false, but
the forwarding stub doesn't need to be concrete, since
isGenericCovariantImpl is inherited from the base class.  (Previously
that situation didn't work because by the time we processed the
inheritance of isGenericCovariantImpl, we had already created a
concrete forwarding stub).

Additional fixes in this CL (necessary to get tests to pass in
meaningful ways):

- Updated InstrumentationValueForForwardingStub to print covariance
  annotations on type parameters.

- Updated _createForwardingStub to copy covariance annotations from
  the target procedure to the procedure being created.

- Moved call_through_this.dart from runtime_checks/ to
  runtime_checks_new/ because the analyzer implementation doesn't
  handle this case correctly.

Change-Id: I984a46826a3a4d8ad1a1ce840269498df049fef0
Reviewed-on: https://dart-review.googlesource.com/13963
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-16 04:07:18 +00:00
Paul Berry 655d3ce665 Account for forwarding nodes when looking up inherited members in InterfaceResolver.
This allows covariance information to propagate properly between
classes and avoids creation of unnecessary forwarding stubs.

Change-Id: Ib55c62adb74d16f94282e752e387634086001946
Reviewed-on: https://dart-review.googlesource.com/12600
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-10 15:55:14 +00:00
Paul Berry 830e68e72d Test whether forwarding stubs handle default arguments correctly (they don't)
This test demonstrates issue #31027.

Change-Id: I2d9e8464b0304e1d41ddc775e8b5ffd37b6e8655
Reviewed-on: https://dart-review.googlesource.com/11141
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-10-06 22:38:46 +00:00
Paul Berry 039f82f7ed Include generic covariance annotations for type parameters in kernel output.
This was inadvertently left out of f94d3950ad.

Change-Id: Ifc3bbd8358322e112bf6b57fc751570d6101c9b6
Reviewed-on: https://dart-review.googlesource.com/11561
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-05 21:40:53 +00:00
Paul Berry 0d931bb75f Take forwarding stubs into account when performing type inference.
Change-Id: I5e6af73ee59458d9324bc48bfb47c06e437cb836
Reviewed-on: https://dart-review.googlesource.com/11644
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-05 21:31:10 +00:00
Paul Berry f94d3950ad Include generic covariance annotations in kernel text output.
Change-Id: I81a7b3ea692e94d7e9bbd8562f1771a7626e0715
Reviewed-on: https://dart-review.googlesource.com/10803
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2017-10-05 05:23:43 +00:00
Paul Berry 7c82b747f8 Actually store forwarding stubs in Class objects.
Change-Id: I3792688a61cdba49b38a8da7f27e9b305fa7a54e
Reviewed-on: https://dart-review.googlesource.com/10704
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-10-04 17:30:49 +00:00
Peter von der Ahé cda4f284b0 Implement warnings on unresolved this-sends.
Change-Id: Ia9ab202e157102c22b2705d13582d3529288f81e
Reviewed-on: https://dart-review.googlesource.com/8502
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2017-10-04 08:21:32 +00:00
Paul Berry 17a4f66126 Instrument the creation of forwarding stubs.
Change-Id: I98d15cdeaff72da4b6e4b8532689c24f42b6d501
Reviewed-on: https://dart-review.googlesource.com/9860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2017-09-30 18:27:25 +00:00