Commit Graph

242 Commits

Author SHA1 Message Date
Martin Kustermann 0cd9497f96 [VM] Skip all language_2 tests on the **VM** in non-strong mode configurations
Some legacy VM configurations, i.e. non-strong mode VM configurations, will no
longer run the `language_2` tests after this CL, since

   * these configurations run already on the legacy `language`
   * we have many status file entries which are due to legacy mode not
     supporting Dart 2.0 semantics
   * people get regularly beaten by this when adding new tests, which
     usually just results in more status file entries
   * nobody is looking at these status file entries

Change-Id: Ief92d1da616a62572fb20c6c1198bbe818ea180a
Reviewed-on: https://dart-review.googlesource.com/55168
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-05-15 14:26:26 +00:00
Samir Jindel 184e2a8b4c [vm] Support partial instantiation of noSuchMethod forwarders in VM.
This is complicated by the fact that the normal factory method for creating
Invocation objects references the arguments descriptor to determine how many
type arguments are passed. This doesn't work for partially instantiated
closures, because the arguments descriptor will say "0" type arguments even when
there may be delayed type arguments attached to the closure from partial
instantiation. The arguments descriptor can't be modified, so we have a new
factory method which takes the number of delayed type arguments directly.

Change-Id: Ic9a35a482b3b7ef80564e674cc6207873e255111
Reviewed-on: https://dart-review.googlesource.com/54245
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-05-14 14:34:58 +00:00
Aske Simon Christensen f5130108ea Some triage of missing compile-time errors in Fasta
Change-Id: Ia7601f7296e2da66ca234a94c57105c366d94a06
Reviewed-on: https://dart-review.googlesource.com/52800
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
2018-05-14 10:18:17 +00:00
Alexander Markov 400c1f1797 Update status for passing test after constant evaluation was reverted
This is a follow-up to reverting constant evaluation in
46ab040e58.
The issue https://github.com/dart-lang/sdk/issues/33086 appears only
if constant evaluation is enabled.

Change-Id: I719f1fde3cf8a87150a815ce7a6cdab68e26eef9
Reviewed-on: https://dart-review.googlesource.com/54709
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-11 20:10:49 +00:00
Samir Jindel 0cafdc4fdb [vm] Fix handling of all-dynamic type arguments in noSuchMethod.
This fixes #33073 for all code which is relevant to Dart 2.

Change-Id: I3956bf9f2bb06f0e67c8b643e8a7765f28464f5f
Reviewed-on: https://dart-review.googlesource.com/54260
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-05-10 17:06:42 +00:00
Dmitry Stefantsov f61e1c0fb3 Mark metadata_test as failing on dart_precompiled
Bug: http://dartbug.com/33086
Change-Id: Id3105e980cf28b8f7bacbe40944f7e28001b23c5
Reviewed-on: https://dart-review.googlesource.com/54406
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-05-09 13:58:03 +00:00
Jenny Messerly 3002e47e36 cleanup language_2 and corelib_2 tests that import dart:mirrors
Preserves tests that didn't really need mirrors, and moves tests for
mirror functionality into lib_2/mirrors tests.

Change-Id: Ie16dee1a4b508e3f14da53499f57c5dae2d1e513
Reviewed-on: https://dart-review.googlesource.com/49624
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2018-05-07 23:50:56 +00:00
Samir Jindel 772c9bb5f3 [vm/kernel] Re-land partial instantiation of local functions.
This change has been adjusted to account for the recent fix to Internal_prependTypeArguments.

Reviewed-on: https://dart-review.googlesource.com/50980
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Change-Id: I434a42578b91f0930b088c4d264d882c3ef5b4a3
Reviewed-on: https://dart-review.googlesource.com/53801
2018-05-05 21:26:37 +00:00
Paul Berry 8f52be2282 Don't infer types when there's an irreconcilable type mismatch.
Also fix the type inference algorithm so that when it explores
multiple alternatives (as a result of the use of FutureOr<>), if one
alternative generated some constraints but failed to produce a match,
it rewinds those constraints and tries the other alternative.
(Previously, it erroneously assumed that if any constraints were
generated, the alternative matched successfully).

Also add unit tests to verify the proper operation of the subtype
match algorithm.

Fixes #32305.

Change-Id: I060b5d6d5247a68d2b27bba78819bae172e43d97
Reviewed-on: https://dart-review.googlesource.com/53685
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
2018-05-03 23:27:14 +00:00
Bob Nystrom bed71b7776 Migrate and clean up the prefix negative tests.
Since there were already non-negative tests with the same numbers, I
gave them meaningful names.

Merged a couple of tests into the same file when it made sense since
multitests let us do that.

Deleted prefix1_negative_test, because it essentially tested only that
a random identifier does not resolve, which is not particularly related
to prefixes.

Change-Id: I91718f6df5126f123d9a8ea3abbc6898797db2db
Reviewed-on: https://dart-review.googlesource.com/52985
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-05-02 16:05:25 +00:00
Bob Nystrom 881e35ee82 Migrate library_negative_test.
In the process, I discovered multitests can't handle imports to
non-existent libraries. So I fixed that and cleaned up the code.

Change-Id: I9a8557e84f91ba7858bdf98f8732cd0ded55aa1a
Reviewed-on: https://dart-review.googlesource.com/52869
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-04-27 22:28:27 +00:00
Aske Simon Christensen 9c2fcedaf4 Error on missing method implementation in non-abstract class
Bug: https://github.com/dart-lang/sdk/issues/32013

Change-Id: I163a84e70e94852a05ce99b07ec883c610ea788c
Reviewed-on: https://dart-review.googlesource.com/52320
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-04-24 13:07:54 +00:00
Johnni Winther be47fa67aa Fix dart2js subtyping
A<dynamic> is _not_ a subtype of A<int> in Dart 2

Change-Id: I0d1185b38192a06aaf9d8622a78c7384dfc287dc
Reviewed-on: https://dart-review.googlesource.com/52106
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-04-20 21:44:09 +00:00
Aske Simon Christensen f06118ef8f Dart 2 fixes to various tests.
All fixes are related to the requirement that a concrete class must
implement its entire interface or have a non-trivial noSuchMethod
implementation.

Change-Id: I015e0565e5dd9cfa324c38bb43696e365c58329a
Reviewed-on: https://dart-review.googlesource.com/51880
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-04-20 12:57:19 +00:00
Aske Simon Christensen 2b09c1efc0 Revert "Error on missing method implementation in non-abstract class"
This reverts commit 7cc55d0372.

Reason for revert: More test fixes needed.

Change-Id: Ib36159184ffbd14ce3f7cca184ce2b8cdfec237c
Reviewed-on: https://dart-review.googlesource.com/51680
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2018-04-18 17:27:22 +00:00
Aske Simon Christensen 7cc55d0372 Error on missing method implementation in non-abstract class
Closes https://github.com/dart-lang/sdk/issues/32013

Change-Id: I8f49d2640ef92a3d9d723969208cdb5f397e806d
Reviewed-on: https://dart-review.googlesource.com/43660
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-04-18 14:39:09 +00:00
Alexander Thomas 3851591642 [infra] Keep comments intact when updating status files.
* Preserve empty lines in the file header.
* Add empty entry to the tool's newly created sections.
* Remove extra empty line at the end of the file.

Change-Id: I271583774d5f5497025a9d85bcadf8b0b9e39e81
Reviewed-on: https://dart-review.googlesource.com/37600
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2018-04-10 19:03:21 +00:00
Sigmund Cherem 0284fdab6b dart2js: allow as expressions in constants
The CFE doesn't allow them explicitly yet, but implicit casts do show up by the
time we see them in dart2js.

Closes https://github.com/dart-lang/sdk/issues/32773

Change-Id: Idb566625ce7c8edc74a4eea0109491bd72357051
Reviewed-on: https://dart-review.googlesource.com/49801
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-04-06 00:46:30 +00:00
Erik Ernst fdc787efc8 Adjusted issue numbers of a test
This is a "small" CL: Only comments in status files are changed.

Issue 31359 was split into a meta-bug 32782 and several other tool
specific issues, because 31359 was reported for dart2js-with-kernel,
but the problem affects several tools.

Change-Id: Ib47032aa622e232f24348bb55bc17d39a971cc2f
Reviewed-on: https://dart-review.googlesource.com/49701
Reviewed-by: Erik Ernst <eernst@google.com>
2018-04-05 14:35:55 +00:00
Stephen Adams c5caf7e294 dart2js: Pass through type arguments in parameter defaulting stubs
This fixes a problem where a defaulted optional argument
would cause the passed type parameters to be replace with dynamic.

Change-Id: I32cf327b3a4b6176f199164c840a1114fc302205
Reviewed-on: https://dart-review.googlesource.com/49081
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-04-04 00:20:41 +00:00
Erik Ernst c98df5b065 Check that type alias equality relies on the underlying type, not the typedefed name.
Note that this is a multi-test, which is helpful in order to make it visible which situations are covered and which ones are not, but when it all works it would make sense to just run everything in one step, in order to get better performance.

Change-Id: Ifab94f7ad369a7c76bab3337eabf2ddd22821b04
Reviewed-on: https://dart-review.googlesource.com/47882
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-04-03 12:34:40 +00:00
asiva a0470fefb6 Remove implicit_creation/implicit_new_or_const_composite_test from the status file under darkp as the test now passes.
Change-Id: I672127172ffcfcdc603d90671bb7e51c2d0b4dda
Reviewed-on: https://dart-review.googlesource.com/48960
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-03-31 01:53:31 +00:00
asiva 996a66d247 Fix build bot failure in dartkp mode (language_2/implicit_creation/implicit_new_or_const_test now passes)
Change-Id: Ic079d4012cee62fe4c42321dbe2c5a795e90b890
Reviewed-on: https://dart-review.googlesource.com/48921
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-03-30 22:38:43 +00:00
Jenny Messerly bed5debbeb Callable object support in Analyzer and DDC.
Fixes #32156
Fixes #32157
Fixes #32426

This also fixes `implements Function` so it has no effect in Dart 2
(it is ignored for the purposes of subtyping.)

Change-Id: Ibec9c77cd516b8b97fef68a579998598d0acf8c6
Reviewed-on: https://dart-review.googlesource.com/45141
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2018-03-30 18:14:55 +00:00
Régis Crelier 85b4c604c5 [VM runtime] Improve type error messages in Dart 2 (fixes #32564).
Hide private class _Future and map it to core lib class Future.
In Dart 2, show dynamic as type argument(s) of raw generic types.

Change-Id: I70b0e1707bc767d04838ac12d16b3ad15623f51f
Reviewed-on: https://dart-review.googlesource.com/48502
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-03-28 17:12:04 +00:00
Samir Jindel 8d669c9d4e [kernel] Update NSM-forwarding test expectations.
Change-Id: Ib212a109a8115e2e387526f61c07840be5c35b76
Reviewed-on: https://dart-review.googlesource.com/47960
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-03-22 19:49:09 +00:00
Dmitry Stefantsov 2fcdfc1f23 Rename bug32353{,_2}_test.dart to issue32353{,_2}_test.dart
Change-Id: Id00f2713dda2fcb62d43d5f7f2034b8f09bb12c1
Reviewed-on: https://dart-review.googlesource.com/46020
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-03-12 10:50:17 +00:00
Dmitry Stefantsov e66733dd60 Simplify test case bug32353_test and decouple it from dart:io
Bug: http://dartbug.com/32353
Change-Id: I941e15ed9f7dcc10c1ea1a0b3ff3acdee92487de
Reviewed-on: https://dart-review.googlesource.com/45503
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-03-09 13:45:58 +00:00
Alexander Markov 7aa3e54acf [vm] Fix computation of hashCode of a closure with null receiver
As tests/language_2/tearoff_dynamic_test.dart shows, it is perfectly
valid to take a tear-off of an instance method from null, and then call
hashCode from such tear-off.

The implementation of hashCode for closures, Closure::ComputeHash()
was calling Instance::Cast(receiver) which asserts for null.
This code is revised to allow null receiver.

Change-Id: I85cc7abf25aab99590b53403904e8bac25328308
Reviewed-on: https://dart-review.googlesource.com/45749
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-03-09 00:26:31 +00:00
Paul Berry db08061424 Handle implicit tear-off of .call when an implicit downcast is required
Previously, we were setting `expression` incorrectly after generating
the implicit tear-off of .call, so if an implicit downcast was needed
as well, it was not attached to the proper kernel node, and the
resulting kernel representation was invalid.

Addresses the front end manifestation of #32426.

Change-Id: Ibd86b75c54a53db1fc4606b7583910c57e1c4aae
Reviewed-on: https://dart-review.googlesource.com/45522
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-03-07 13:59:39 +00:00
Peter von der Ahé 94aa20dd07 Update status for $compiler == fasta
Change-Id: I5d073d1c678dc313e79193074c6491085c093596
Reviewed-on: https://dart-review.googlesource.com/45381
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-03-07 10:32:33 +00:00
Johnni Winther d3c3ac48a3 Remove implicit 'implements Function' for strong mode
Change-Id: Ie3e3e11a727f7fbe3c8d7af17c84dedfbdfcdf3a
Reviewed-on: https://dart-review.googlesource.com/44422
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-03-06 09:18:48 +00:00
Paul Berry 2993476129 Report an error if a class inconsistently implements a generic interface.
This is not allowed in Dart 2.0.

Change-Id: I6861ce298e5d5a5cf3f26a010990868b5ba9bda2
Reviewed-on: https://dart-review.googlesource.com/39601
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-05 12:13:12 +00:00
Paul Berry 11cbdbe26e When checking mixin type inference errors, don't skip mixins with explicit type args.
Fixes #32372.

Change-Id: I77bcdcdb5a764ba1d6075176800fa038aa46a1f9
Reviewed-on: https://dart-review.googlesource.com/44440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-03-05 09:10:01 +00:00
Jens Johansen 80e2d30c20 [vm] Fix issue causing recursive_mixin_test to crash
In the VM, TypeRef (extending AbstractType) did _not_ implement
error(), meaning that callong error() on such a type would call it in
AbstractType which basically just says `UNREACHABLE();`.

This fixes the issue.

Change-Id: I6cb9ebe8f814296db8383c187c880f367b096312
Reviewed-on: https://dart-review.googlesource.com/44420
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-03-02 17:39:39 +00:00
Paul Berry b1a5325171 Suppress "extends" check when inferring mixins.
This should be safe since the purpose of the inference is to find an
exact match for each type parameter; if an exact match is found but it
doesn't satisfy the "extends" constraint, that will be detected and
reported later.  If an exact match isn't found, the type bound will be
filled in my instantiate-to-bounds.

Addresses the analyzer portion of issue #32353.

Change-Id: Ic9f71eefac2fa3f6f126957b9d1652ca1d990b89
Reviewed-on: https://dart-review.googlesource.com/44220
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-03-01 05:55:26 +00:00
Jens Johansen 7b4ad246b7 [kernel] Fix crash in mixin resolution on invalid override
Change-Id: I602fe4aaed1520ead002933a41ca75527e93e4af
Reviewed-on: https://dart-review.googlesource.com/42746
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-27 14:14:08 +00:00
Jens Johansen ac7f580005 Support Kernel Instantiation node in VMs constant evaluator
Fixes #32268.

Bug: 32268
Change-Id: I7d2ebc28d19aca623460cd1dacc86b64893810ac
Reviewed-on: https://dart-review.googlesource.com/42949
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-02-23 07:02:45 +00:00
Jens Johansen e8026c1e76 [fasta] Fix crash on dynamic<argument>
Change-Id: Ibebb7bc5b95979cef9254305430b55ce8cb3cb34
Reviewed-on: https://dart-review.googlesource.com/42744
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-22 14:06:03 +00:00
Paul Berry b119f7a4cd Only allow implicit use of .call if it refers to a method.
Change-Id: I4c332b64eb7338ceaf63544c3dd0317f8c7d4538
Reviewed-on: https://dart-review.googlesource.com/42020
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-21 14:12:14 +00:00
Kevin Millikin 1b1fe0be35 Fix a broken language_2 test
As far as I can tell, both of these are intended to be compile-time
errors and not run-time errors.

Change-Id: I7c3ee8b1431d954b3b74e668c88517dc032cd8ce
Reviewed-on: https://dart-review.googlesource.com/41700
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2018-02-19 11:30:07 +00:00
Leaf Petersen 3d6ad7b3a2 Remove fuzzy arrows except on assignability
Change-Id: I00ffa8f6f85cede8badd4d7082da4603f998956c
Reviewed-on: https://dart-review.googlesource.com/40470
Reviewed-by: Jenny Messerly <jmesserly@google.com>
2018-02-17 00:30:56 +00:00
Lasse R.H. Nielsen 1c8b2285c3 Another missing status line.
Change-Id: Iea55aee3689a346ddcbe292209b755c21e2f226f
Reviewed-on: https://dart-review.googlesource.com/41760
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2018-02-15 14:02:31 +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
Paul Berry d9d2dc405b Infer mixin types in the analyzer.
This follows Leaf's simplified suggestion.  As a temporary hack it
assumes that the mixin passes its type parameters through to its
superclass constraint unchanged.

Change-Id: I091b44005d6364a91e20578f2ff6340334b1fab6
Reviewed-on: https://dart-review.googlesource.com/38040
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-02-07 10:45:39 +00:00
Jenny Messerly 8489a843db fix generic_test and generics_test for Dart 2
Change-Id: I831b5b0b6ade4cb099447e6a09058eb5c6745afa
Reviewed-on: https://dart-review.googlesource.com/36562
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
2018-02-01 02:15:25 +00:00
Jenny Messerly 5013b28bbe fix #31999, remove fuzzy arrow runtime support from DDC
Also updates tests that relied on fuzzy arrows.

Change-Id: Ia8df1d8d421e43dfada589223d5e46182b92fa67
Reviewed-on: https://dart-review.googlesource.com/37425
Commit-Queue: Jenny Messerly <jmesserly@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-01-31 22:20:38 +00:00
Régis Crelier ed1d8bd475 [VM parser] Complete support for generalized void (fixes #30516).
'void' is now allowed as type annotation for locals, fields, and formal
parameters, in addition to being previously allowed as type argument.
Update status files.

Change-Id: I6459f56824dc0a695615d8dc87c9a8a1f9be29ef
Reviewed-on: https://dart-review.googlesource.com/37651
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-01-31 00:56:41 +00:00