Commit Graph

19050 Commits

Author SHA1 Message Date
Konstantin Shcheglov a412f24e41 Add tests for highlighting implicit instance creation.
And in general run analysis server tests with `previewDart2 = true`.

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

Change-Id: I063d667e96a46d60d3b10aa1a87b4c7a7d2252e5
Reviewed-on: https://dart-review.googlesource.com/42101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-16 20:52:01 +00:00
Dmitry Stefantsov 629bef0a91 Apply special rules to assignability check for async bodies
Fixes #32185

Bug: http://www.dartbug.com/32185
Change-Id: I07d35679d08c4aef38029b83f0d495cf05a02366
Reviewed-on: https://dart-review.googlesource.com/41940
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-02-16 20:14:18 +00:00
Konstantin Shcheglov dcefeb17b6 Set ClassElement implicit instance creation.
I also changed tests to be a bit more specific - test whether elements
are class and constructor where one is expected. Not found additional
problems though.

R=brianwilkerson@google.com

Change-Id: I95cf57e46620149740d6c748a6065b3b2e00409e
Reviewed-on: https://dart-review.googlesource.com/42027
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-16 19:49:57 +00:00
Brian Wilkerson 3d183f6999 Add support for selection ranges to ChangeBuilder
Change-Id: Icd4c1bcf2ecb66020a9a7f478a037c478e8a109f
Reviewed-on: https://dart-review.googlesource.com/42024
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-16 19:23:06 +00:00
Konstantin Shcheglov b17ac68b60 Add <Widget> type arguments for wrapping with Column/Row.
R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I6e8ee33c453e552965d14ecb95391eb55b7b0bc6
Reviewed-on: https://dart-review.googlesource.com/42025
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-16 18:45:17 +00:00
Konstantin Shcheglov 6e912ff3ed Don't cast to LibraryElementImpl.
Also run PreviewDart2Test with analysis driver, that's how it is actually
used.

R=brianwilkerson@google.com

Change-Id: I6757d7435c376a07fa1ef00b495b5fab0d118924
Reviewed-on: https://dart-review.googlesource.com/42023
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-16 18:17:07 +00:00
Konstantin Shcheglov 6790cc30ef Highlight class names in instance creations as constructors.
This is needed for better highlighting optional new/const. I think the
main reason is that 'new' is highlighed and we knew that this is a
new instance creation. Constructors are also highlighed in the default
color scheme. But class names are not. So, to make code look colorful
again, we need to highlight class names in instance creations.

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

Change-Id: I8fde0b4aa5243e94d7ba575a74d52d31d3b665bb
Reviewed-on: https://dart-review.googlesource.com/42021
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-16 17:50:27 +00:00
kmillikin b36633357c Make the Kernel clone visitor more robust
Instead of extending the TreeVisitor which provides an incorrect
implementation of all methods, merely implement the TreeVisitor to
require an implementation in CloneVisitor.

Change-Id: Ied7d3b8062ee380e766c737e844a24b0b746312d
Reviewed-on: https://dart-review.googlesource.com/41926
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
2018-02-16 16:28:47 +00:00
Vyacheslav Egorov d869604387 [vm/kernel/aot] Rename Selector.get/set into Selector.doGet/doSet.
This is a workaround for issue #32196 which breaks Flutter engine
build when frontend_server tries to train by parsing itself.

Change-Id: I5c0d505f41ad5417bcc6a0f66663f28fed192e35
Reviewed-on: https://dart-review.googlesource.com/41983
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-02-16 14:51:17 +00:00
Brian Wilkerson 0501c740ac Member overrides invoke the overridden member and the display label uses ellipses
Change-Id: I9cb2db1514a8a2798cb3ec69d3d71047573a8dd4
Reviewed-on: https://dart-review.googlesource.com/41903
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2018-02-16 14:12:27 +00:00
Peter von der Ahé fd19dfe5f5 Remove IncrementalClassHierarchy
Change-Id: Ie141648f8fbc97a025e90cc456265a51c3da0b04
Reviewed-on: https://dart-review.googlesource.com/41823
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-16 09:13:46 +00:00
Peter von der Ahé 2191139a1a Fix crash in mixin canonicalization
Change-Id: Ifcb15672816aae04833c18fa6954336e680ddda7
Reviewed-on: https://dart-review.googlesource.com/41820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-16 09:00:16 +00:00
Konstantin Shcheglov 670c288711 Issue 32162. Fix for crash in generic function type argument of unresolved class.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/32162
Change-Id: I0a2df5bf5a08b52a7eb47e1b8265b9bbbf65e599
Reviewed-on: https://dart-review.googlesource.com/41922
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-16 01:01:16 +00:00
pq 3dd7eae4c8 Add @required prefix to required params.
See: https://github.com/flutter/flutter/issues/10219
Change-Id: If8bd55b5a3557f8c49430079b790727f7ba25217
Reviewed-on: https://dart-review.googlesource.com/41924
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-16 00:13:30 +00:00
Konstantin Shcheglov 4039224d5c Don't set the exit position for Flutter Quick Assists.
We decided that we don't want to move caret under the user.

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

Bug: https://github.com/dart-lang/sdk/issues/32184
Change-Id: I86199bb060fbbbb8e521572d046b3fcdef80f74d
Reviewed-on: https://dart-review.googlesource.com/41920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2018-02-15 23:54:06 +00:00
Jacob MacDonald 0bda5c9015 get source_map_stack_trace working for the external world
Bug:
Change-Id: I7385f2f1f11742ce5f90cce67b863ba066074679
Reviewed-on: https://dart-review.googlesource.com/41921
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2018-02-15 22:45:26 +00:00
Konstantin Shcheglov d9a44c9dc7 Revert "Normalize Windows drive letters to uppercase for analysis"
This reverts commit 56acaee9b1.

See https://github.com/dart-lang/sdk/issues/32186

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

Change-Id: I76c673758e4b9acd22044985b4054b5504f4a205
Reviewed-on: https://dart-review.googlesource.com/41902
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-15 22:10:56 +00:00
Konstantin Shcheglov 7d0877dbf6 Remove unused methods in assist/fix tests.
R=brianwilkerson@google.com

Change-Id: I6aa5ef067bb3cee4cbd8ffc01bf60bf0637f773e
Reviewed-on: https://dart-review.googlesource.com/41880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-15 19:13:35 +00:00
Konstantin Shcheglov 1e999ed9fe It is OK to inline Column with a single item in 'children' into a 'child'.
R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: Ifa2a300b2735ab635bbaeeee08ce21ad8a7db9b7
Reviewed-on: https://dart-review.googlesource.com/41901
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-15 18:25:57 +00:00
Konstantin Shcheglov 95f336a667 Don't suggest imports of private libraries from other packages.
R=brianwilkerson@google.com, devoncarew@google.com

Bug: https://github.com/flutter/flutter-intellij/issues/1661
Change-Id: I5e458e8815d4f8df3e2f22bdfdc21c7203cefde0
Reviewed-on: https://dart-review.googlesource.com/41620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-15 17:11:56 +00:00
Peter von der Ahé 3c773f68bc Start on a tree factory to abstract AST node creation
Change-Id: I3db98c2f7eaa93a0df6ff848fb57d5b7e4cd2482
Reviewed-on: https://dart-review.googlesource.com/41681
Reviewed-by: Paul Berry <paulberry@google.com>
2018-02-15 15:13:29 +00:00
Jens Johansen 57f6b42313 [kernel] Buffer (all) small writes when writing dill
When writing a dill file, certain things are written to the
BufferedSink via addBytes.

In the case where the BufferedSink currently has nothing buffered and is
given a input that is deemed small, prior to this CL, the data was added
directly to the underlying sink. As such a million _sink.addBytes([42])
in a row would make at least 900,000 (the buffer size is 100,000) calls
to the underlying sink.
For `new File(path).openWrite()` that takes a while.

This CL fixes it by always buffering the small writes, reducing the
number of calls to the underlying sink to 10 in the above case.

Change-Id: I097f490d57b0a27b3175d6bb4ef513851acc503e
Reviewed-on: https://dart-review.googlesource.com/41740
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-02-15 14:01:28 +00:00
Jens Johansen 00c9af8522 [fasta] Fix crash when importing nonexisting "dart:" uri
Previously, importing a nonexisting "dart:" uri resulted in a crash in
fasta. This CL introduces a test and fixes the problem.

Fixes #31172.

Change-Id: I61b2668466f2567e5e5dcaff3203f0c5ee9a885f
Reviewed-on: https://dart-review.googlesource.com/36401
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-02-15 14:00:17 +00:00
Peter von der Ahé 3e61365696 Add --legacy-mode option.
This is a step towards removing the option --strong-mode because
it's supposed to be on by default.

Change-Id: I25da0038d12e359f9c628beb2f92293295f00185
Reviewed-on: https://dart-review.googlesource.com/39983
Reviewed-by: Jens Johansen <jensj@google.com>
2018-02-15 09:54:20 +00:00
Peter von der Ahé 5d8a9e8403 Rework command-line option parsing to enable default values
Change-Id: I3e53f38e6f242351c0f41b85fbad534c00663f9e
Reviewed-on: https://dart-review.googlesource.com/39982
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
2018-02-15 09:27:17 +00:00
Jenny Messerly b371ed5db3 fix #32140, locals shadowing constructor/catch params
This gets DDC and DDK to handle the block body of functions/methods in a
similar way, eliminating it from the JS if it is not necessary, and fixes
a bug in DDC for cases where we do need to emit a nested block scope.

Change-Id: I37d3d69bfcf9b1204385cca7785601fb7d6edfc3
Reviewed-on: https://dart-review.googlesource.com/41565
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
2018-02-14 23:43:13 +00:00
Brian Wilkerson f5942a5ce0 Add support for analyzing analysis options and pubspec files
Change-Id: I2aa05e5822b2993d0f1e903396c816b52e2292b4
Reviewed-on: https://dart-review.googlesource.com/41566
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 22:50:05 +00:00
kmillikin b019045393 Front-end implementation of mixin type inference.
Infer missing type arguments to generic mixin classes in mixin
applications based on mixin supertype constraints.  The implementation
directly follows the draft feature specification at
https://dart-review.googlesource.com/c/sdk/+/38940.

Bug: https://github.com/dart-lang/sdk/issues/31984
Change-Id: I7caba037b1b0e73c44f71aaa958f3ff3e8f3c1f0
Reviewed-on: https://dart-review.googlesource.com/40661
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-02-14 22:43:24 +00:00
Mike Fairhurst 85973b9a54 Simplify analysis server's excluded file handling
Change-Id: I30bc19e7c185cb3dffbe5b84d0bd3f7b5b6f585b
Reviewed-on: https://dart-review.googlesource.com/41562
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2018-02-14 22:25:54 +00:00
Dmitry Stefantsov ec9c927b18 Resolve type arguments of redirecting factories invocations
Fixes #32068

Change-Id: Ifc2c832d5a761ae51b7f93084543aa04902a9529
Reviewed-on: https://dart-review.googlesource.com/40280
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-02-14 22:03:23 +00:00
Mike Fairhurst 470f28e3c6 Fix #31345 include analysis_options breaks some properties
Bug: 31345
Change-Id: I8d588cc49931ccb4699cc33c8e12a7f701a0a513
Reviewed-on: https://dart-review.googlesource.com/41500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2018-02-14 21:32:44 +00:00
Janice Collins 121a8ebcb2 Prepare for analyzer 0.31.2-alpha.0.
Update changelog and versions prior to publish, primarily for the crash
in computeNode fixed by https://github.com/dart-lang/sdk/commit/3791ddb496a2d8c9ed9bc2edcc62e562c2e47eb2#diff-ff9cb85838db7a802ac5aa9c55f26d86.

Change-Id: If3bbe3238fb622d884cee5df87a06a90b401fe7e
Reviewed-on: https://dart-review.googlesource.com/41040
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 21:22:54 +00:00
Konstantin Shcheglov 425e07d721 If selection in 'Extract Method' does not cover any node, extract the smallest covering expression.
Two comments.

1. We need also to change the Dart plugin for IntelliJ to not select
   the whole line when selection if empty. The whole line is almost
   never a good choice for Flutter.

2. This is not fully consistent with "Extract Lolal" where we give the
   client the list of possible expressions to extract and the user can
   then choose. Here we use just the smallest one. If we want to make
   it consistent, we will need to enchance the protocol and the plugin.

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

Change-Id: I87a752234d9c825d78a6d787d2b21d1b252166c2
Reviewed-on: https://dart-review.googlesource.com/41520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-14 20:43:13 +00:00
pq be4040214c Enable @override completion contributions.
See: https://github.com/flutter/flutter-intellij/issues/1110
Change-Id: Iaddb5e9818f737889a484f562febcb4ca72d1017
Reviewed-on: https://dart-review.googlesource.com/41483
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 20:23:59 +00:00
Konstantin Shcheglov b5cb793fbd Convert unresolved 'children:' into 'child:'.
R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I3ea3f8a8be2e942a3fd00060519a7dbfeae6fb36
Reviewed-on: https://dart-review.googlesource.com/41481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-14 20:23:43 +00:00
Ross Wang 879431330e Bumping protobuf version to ^0.7.0
Fuchsia is including some dart proto code that expects protobuf 0.7.0.

Change-Id: Ie42a3751a2d3a7e51e759b9913d0901ecefafc70
Reviewed-on: https://dart-review.googlesource.com/40480
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-02-14 19:28:23 +00:00
Konstantin Shcheglov 4232ac99e8 Fix for surround-with linked edit positions.
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/sdk/issues/32106
Change-Id: Ia899171aa38dd1283b72cdd100a0f5b678e9b565
Reviewed-on: https://dart-review.googlesource.com/41420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-02-14 18:55:33 +00:00
Brian Wilkerson ae5534a394 Handle cases where a non-dart file is being edited (issue 32160)
Change-Id: Icd7d1ff0ecb4515163281c9a85a1b1927e864fbe
Reviewed-on: https://dart-review.googlesource.com/41400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 18:27:33 +00:00
Dan Rubel 577fc049d8 Update fasta parser recovery tests
Change-Id: Ie2116e9c99c615238199542a147c7240f31fb659
Reviewed-on: https://dart-review.googlesource.com/41101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-14 18:01:14 +00:00
Dan Rubel dd0a08a75e Improve fasta parser error reporting
This CL updates the fasta parser to report more errors
and have improved recovery. The new errors reported include:

* IllegalAssignmentToNonAssignable
* MissingAssignableSelector
* StaticConstructor

In addition, a number of test expectations were updated
to match the errors already produced by the fasta parser.

Change-Id: I99889e8e64663ca5b81a5d5d8f5e5241d049a0a2
Reviewed-on: https://dart-review.googlesource.com/41100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 18:01:14 +00:00
Brian Wilkerson a83bcc8235 Check for unresolved imports too avoid breaking when handling optional new and const (issue 32150)
Change-Id: Ia7cc162e0e615ce324acb230e1d0bbf59d89ffa1
Reviewed-on: https://dart-review.googlesource.com/41380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-14 17:42:13 +00:00
Brian Wilkerson 75a2a1524f Support updated optional new and const spec
Change-Id: I974185eba4936f14d7b9d5d1d5c1638a37624c62
Reviewed-on: https://dart-review.googlesource.com/41024
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-02-14 17:12:13 +00:00
Devon Carew 7579c58fad Rename 'Add widget padding' to 'Add padding'.
Change-Id: I9483e4ed3abe5ccad000b04ed7fe1098ac977e90
Reviewed-on: https://dart-review.googlesource.com/41320
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2018-02-14 16:50:53 +00:00
Vyacheslav Egorov 286b123d35 [vm/kernel/aot] Remove type checks from non-dynamically-invoked implicit setters
This applies optimization from d117760 to implicit setters.

(This CL also reformats kernel_binary_flowgraph.cc because some previous CL
was pushed without proper formatting)

Bug: https://github.com/dart-lang/sdk/issues/31798
Change-Id: I6f1590bfd40e36b972b857c49d6ce8435bb25187
Reviewed-on: https://dart-review.googlesource.com/41300
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-02-14 16:24:03 +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 421db9c69c Re-land "Implement proper checking for callability of Function class."
(was reverted in https://dart-review.googlesource.com/c/sdk/+/40980
due to an analyzer bot breakage)

Original commit message:
Implement proper checking for callability of Function class.

There was some old (incorrect) logic for doing this, behind the flag
enableStrictCallChecks.  This flag has been removed, since the new
behavior is now standard in Dart 2.0.

Fixes #31509

Change-Id: Ice5cf38bbc648badf7f2563ff930b69f9a799635
Reviewed-on: https://dart-review.googlesource.com/41120
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-14 11:30:23 +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
Stephen Adams df3c210cbb dart2js: Local type information erasure
Change-Id: I28ed9e313159222982a4093cc898339a558c5fd9
Reviewed-on: https://dart-review.googlesource.com/35813
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2018-02-14 07:58:01 +00:00
Régis Crelier 4c9a842d61 [corelib] Cleanup isValidInt and toInt() in new BigInt implementation.
Change-Id: I1f107d4f6e26ea3644bc6c9f7cff5ee6fac43958
Reviewed-on: https://dart-review.googlesource.com/40512
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-02-14 03:43:52 +00:00