Commit Graph

1769 Commits

Author SHA1 Message Date
Anna Gringauze 25559399ed Reland "Implementation of evaluation to JS in frontend server"
This is a reland of 344c584ec4

First attempt failed due to lack of implementation of the new
API from SDK in Flutter/engine that this change introduces.
Fixed by creating dummy implementation in flutter/engine:

https://github.com/flutter/engine/pull/16309

Original change's description:
> Implementation of evaluation to JS in frontend server
>
>     - made ProgramCompiler somewhat incremental by letting the user
>       set the current library and class
>     - fixed a bug in procedure_builder where extension method wrappers
>       did not have correct fileEndOffset set, which prevented finding
>       dart scope at a line when extension methods are used
>     - added new compileExpressionToJs API to frontend server and
>       frontend compiler interface
>     - added ExpressionCompier class that combines IncrementalCompiler
>       and ProgramCompiler to compile expression at given dart location
>       to JavaScript
>     - in JavascriptBundle, set the module name for library tracking in
>       JavaScript and saved program compilers to a table for incremental
>       reuse in expression compiler
>     - Exposed generator from IncrementalCompiler for use in
>       ExpressionCompiler
>     - added tests for expression compiler
>     - added test for compileExpressionToJs API in frontend server tests
>
>
> Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>
> Reviewed-by: Jake Macdonald <jakemac@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I56426d2b6d831b2f8d8c57d468d0b54833a0062e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134561
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-11 18:31:44 +00:00
Mark Zhou eddfbb1776 [dartdevc] Wrapping function types with nullability wrappers.
This is required when comparing functions type objects with sub-canonicalized functions.

Example:
Function() g() => (() => 0) (opt-out)
Function()? f() => null (opt-in)

both canonicalize their return type as a step in canonicalizing the entire function. Omitting a wrapper around the canonicalized function type (the return value) would result in the runtime types of these functions being canonicalized to the same value.

Change-Id: Icb1fd77458267e769bd4d4f54b71d0f81a323bd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133340
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-02-10 18:29:24 +00:00
Nicholas Shahan 35cd61819a Remove dart:mirrors library from dart2js and ddc SDKs
A followup change will delete the patches that are no longer needed once
these changes have been "mirrored" :P to the libraries files in the
flutter repos.

Change-Id: I7d255838b97922198248b29311facd4956001e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134405
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-02-07 17:34:54 +00:00
Nicholas Shahan c438a48bc4 [dartdevc] Enforce more pedantic v1.9.0 lints and cleanup violations
- prefer_generic_function_type_aliases
- use_function_type_syntax_for_parameters

Change-Id: I138d4104c5de41acf44b7962d6e2ce58d78b8a75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134380
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-02-04 23:04:27 +00:00
Nicholas Shahan 3ca719b44c [dartdevc] Enforce omit_local_variable_types lint
Change-Id: I50d9c073ec337d5f05203b30abf289877fdeb08f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134082
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-02-03 23:41:17 +00:00
Vijay Menon 18f41ce9e5 [dartdevc] use var for top-level
This is a potential workaround for:

https://bugs.webkit.org/show_bug.cgi?id=199866

until a proper fix lands in Safari.  See:

https://github.com/dart-lang/sdk/issues/40380

Change-Id: I66f5aefefcc6c8f12fd3b747fcee587fc16d437d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133542
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-31 21:30:32 +00:00
Nicholas Shahan 55b81b08bf [dartdevc] Add dart:io back to the sdk
Revert the changes made to DevCompilerTarget that allowed for optionally
excluding libraries when building the null safe SDK.

Fixes: #39698
Change-Id: I0ae3160e17ca60b7a078a905ea12c8538d2aa045
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134081
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-01-31 20:00:32 +00:00
Jens Johansen 3d5530ff22 [CFE] Transformations can now tell of they changed the structure of a class
By allowing a transformation to tell if it change dthe structure of a
class we can make sure to update the class hierarchy accordingly,
making sure it's up to date for the next computeDelta call in the
incremental compiler.

Change-Id: Iefed3bb1ecbd17b142266ce4a9e1e477f9d2fc87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133222
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-31 13:45:12 +00:00
Nicholas Shahan 40e816b456 [dartdevc] Apply lints and cleanup violations
- always_require_non_null_named_parameters
- prefer_final_fields

Change-Id: I21dc5a9514fe2a7bb09c91fe28b2d4b79d7991e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133840
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2020-01-31 00:47:26 +00:00
Sigmund Cherem 13e3189a2c re-add web libraries as part of the sdk
This undoes what we did to get the sdk building earlier. Most tests in lib_2
had runtime failures because native elements were not tagged as such.

Besides re-adding dart:html et al to the list of compiled libraries, this ensures
we handle native/extension types properly.

(See #39698)

Change-Id: Ib8516c6d92d12d0f5dccdb5a6cf66e0990b52aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133869
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-30 19:00:07 +00:00
Siva Annamalai 0987024f51 Revert "Implementation of evaluation to JS in frontend server"
This reverts commit 344c584ec4.

Reason for revert: It is breaking the flutter builds and is blocking the roll of Dart into Flutter (see https://github.com/flutter/engine/runs/416355895 and
https://ci.chromium.org/p/flutter/builders/try/Linux%20Host%20Engine/3451)

Original change's description:
> Implementation of evaluation to JS in frontend server
> 
>     - made ProgramCompiler somewhat incremental by letting the user set
>       the current library and class
>     - fixed a bug in procedure_builder where extension method wrappers
>       did not have correct fileEndOffset set, which prevented finding
>       dart scope at a line when extension methods are used
>     - added new compileExpressionToJs API to frontend server and
>       frontend compiler interface
>     - added ExpressionCompier class that combines IncrementalCompiler
>       and ProgramCompiler to compile expression at given dart location
>       to JavaScript
>     - in JavascriptBundle, set the module name for library tracking in
>       JavaScript and saved program compilers to a table for incremental
>       reuse in expression compiler
>     - Exposed generator from IncrementalCompiler for use in
>       ExpressionCompiler
>     - added tests for expression compiler
>     - added test for compileExpressionToJs API in frontend server tests
> 
> 
> Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
> Commit-Queue: Anna Gringauze <annagrin@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>
> Reviewed-by: Jake Macdonald <jakemac@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

TBR=aam@google.com,jensj@google.com,johnniwinther@google.com,jakemac@google.com,sigmund@google.com,grouma@google.com,nshahan@google.com,jonahwilliams@google.com,markzipan@google.com,annagrin@google.com

Change-Id: I3dc1ab0117df7b3141b8056ae684fc1c3492b2a3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133867
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-01-30 02:22:40 +00:00
Anna Gringauze 344c584ec4 Implementation of evaluation to JS in frontend server
- made ProgramCompiler somewhat incremental by letting the user set
      the current library and class
    - fixed a bug in procedure_builder where extension method wrappers
      did not have correct fileEndOffset set, which prevented finding
      dart scope at a line when extension methods are used
    - added new compileExpressionToJs API to frontend server and
      frontend compiler interface
    - added ExpressionCompier class that combines IncrementalCompiler
      and ProgramCompiler to compile expression at given dart location
      to JavaScript
    - in JavascriptBundle, set the module name for library tracking in
      JavaScript and saved program compilers to a table for incremental
      reuse in expression compiler
    - Exposed generator from IncrementalCompiler for use in
      ExpressionCompiler
    - added tests for expression compiler
    - added test for compileExpressionToJs API in frontend server tests


Change-Id: Ic5e7829e07030b8ad044da7d35bcf27e9fba81c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132701
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-30 00:54:51 +00:00
Nicholas Shahan e3797b1bb7 [dartdevc] Apply more lints from pedantic v1.9.0 and cleanup violations
- avoid_null_checks_in_equality_operators
- camel_case_extensions
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_for_elements_to_map_fromIterable
- prefer_if_null_operators
- prefer_spread_collections

Change-Id: Iab816e71274a57cbca9b4006dc8dbc55604fcb2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133500
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-01-29 22:14:00 +00:00
Nicholas Shahan 2d5265f59d [dartdevc] Apply always_declare_return_types lint and cleanup violations
In most cases I provided the type that appeared in the return
statements. For a few test files I explicitly typed the return types as
dynamic because it caused diffs in the expected break point locations
when adding more explicit types and it wasn't totally clear what the
new locations should be.

Change-Id: Ifdd80edcccc5fc4a2083ecdbb0e5fbf1c4453e01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133339
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-01-29 07:17:22 +00:00
Nate Bosch 833c70be61 Add the first Kernel check for invalid JS interop
Add a visitor that checks for invalid JS interop usage and reports
diagnostics. Wire the visitor up to the `DevCompilerTarget` and `Dart2jsTarget`.

- Add a message without an analyzer code for this error. In the long term we may
  want to also add it to analyzer.
- Add a new package `_js_interop_checks` to share the kernel visitor between
  dart2js and ddc. Some of the code is copied from ddc, and in the long term we
  can centralize more of the detection of JS interop annotations to this
  package.
- Implement the first check to detect definitions of `operator []` or
  `operator []=` which are not allowed in JS interop classes.

Change-Id: I095a4b7f4732796dbc3cae55b32d5fc9bcdbd798
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130733
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-28 22:39:10 +00:00
Nate Bosch 534e85866d Assert that allowInterop is used with constructors
Fixes a missing case where DDC allows unwrapped functions to flow to
JavaScript through constructor calls or anonymous object instantiation.

- Pass the `Member` through to `_emitArgumentList` in the case of
  constructor calls and object literals so that `isJsInterop` can be
  determined.
- Pass an optional `isJsArgument` member through for emitting named
  expressions. Previously I thought that no named arguments would be
  used for javascript calls, but they are used to create object literals
  for anonymous JS types.
- Add both anonymous and non-anonymous constructor invocation examples
  to the JS interop test.

Change-Id: I004642f3b2caccc0d8c26786f2bdcb081d135898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131462
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2020-01-28 16:59:58 +00:00
Jacob MacDonald 2b221f9b49 Require pre-initialized importToSummary and summaryToModule maps in the ProgramCompiler constructor, and remove the corresponding arguments from emitModule.
This allows these maps to be re-used across multiple instances.

Change-Id: I433538d88dbe0348e2cfa592dae2e17af3dc17b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133150
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-01-24 17:23:09 +00:00
Jacob MacDonald 14544a3e2d Allow http uris in frontend_server, front_end, and ddc.
Also updates StrongComponents to prefer the main component as the root if it is in a cycle. This makes bootstrapping more predictable.

This enables a clean integration of build_runner or ddr (internal) and the frontend_server by allowing it to work with any dev server.

All that is needed is a custom .packages file with `http` uris pointing at a dev server which does all code generation, etc.

Bug: https://github.com/dart-lang/webdev/issues/865
Change-Id: I14533d71e5f7ddac58d98073cf016c2589165e9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132962
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-23 23:47:22 +00:00
Nate Bosch 3eaae5405d Enable and fix directives_ordering lint
Change-Id: I7782bc44f79bb2317921ebf400411d5ef01e11cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132970
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-23 21:01:54 +00:00
Jacob MacDonald 52fd18ac42 Remove multiRootOutputPath special case for package: uris
This was added for the case where the package root is the file system root, but it causes problems for other cases.

Removing this for now, there are no uses yet.

Change-Id: I99cee2d0b9cc8aac63ce4b4ff7f2e25ffc9c21b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133085
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2020-01-23 20:57:54 +00:00
Nicholas Shahan ca260cefdf [dartdevc] Update FutureOr is, as, and _check methods for NNBD
Change-Id: I27a3318f741bba429ed4790f9024ebaea6bfc45b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132743
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-01-23 20:21:19 +00:00
Nicholas Shahan 22c0c9fd83 [dartdevc] Fix nullability wrapping for Never and Bottom types
Created helper for emitting the nullability wrapper around a type. I'm also
using this helper as a way to reduce the number of places we check if the
null safety experiment is enabled to make that easier to cleanup in the near
future.

Change-Id: I928d098b9bdadd96759026f49c58c8fc86cf1aae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132940
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-01-22 22:25:59 +00:00
Jacob MacDonald 76323794b6 code review updates from https://dart-review.googlesource.com/c/sdk/+/132300/6 that I forgot to upload
Change-Id: I99ae4416a57595399cdd158eb47445594cb25996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132742
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-01-21 21:51:29 +00:00
Vijay Menon 038931666b [dartdevc,nnbd] include dart:developer and dart:isolate in built sdk
Change-Id: Icd400895c896b4652f41fdf0a8b36af57084782c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132421
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2020-01-21 18:33:27 +00:00
Jacob MacDonald 4460f95782 Updates frontend_server javascript bundler to be based on import uri instead of file uri.
Converts `package:` import uris into `/packages/` modules.

Also renames the output modules to append `.lib.js` instead of just `.js`. This allows us to distinguish between modules and applications based on extension.

Updates DDC source map code to be able to convert absolute file uris in sources so that they are relative to the source map.

Bug: https://github.com/dart-lang/webdev/issues/865
Change-Id: I55d70aa3761f10cc8bd7e92f5b567478040660de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132300
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-01-21 17:41:02 +00:00
Vijay Menon 8a947deffa [dartdevc] clear console on hot restart
Internal request b/147818704

Change-Id: I08c655c74ea10b6f14ffde8283cbfc286dfae41b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132180
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-01-16 22:07:18 +00:00
Mark Zhou 9b82f1a1f5 [dartdevc] Unbreaking deferred types.
The exact mechanism causing the break isn't obvious but has something to do
with caching withNullability(Nullability.nullable) in _emitInterfaceType.

Kudos to Siggi for pointing out that this change could cause unintended
side effects in https://dart-review.googlesource.com/c/sdk/+/130727
(that I unfortunately didn't heed)!

Bug: https://b.corp.google.com/issues/147802360
Change-Id: I608a7c5485b4301360476439d9240bd5a73d3ad3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132040
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-16 20:22:18 +00:00
Jens Johansen 128771af8a [CFE] Version 2 of incremental compiler invalidation strategy
Change-Id: Iff860e2665dee64fc005a50237ae890986ddb0f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127896
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-16 07:50:39 +00:00
Mark Zhou 515d4bd7ad [dartdevc] Emitting equality checks that disregard 'legacy' wrappers for type objects.
Currently does not work for function and generic function types.

Type object equality ignores legacy modifiers but preserves other nullability
semantics. This scheme constructs the runtime type object (normalized) at runtime,
caching it if necessary. This avoids the space overhead of emitting canonicalized
normalized types at compile-time but incurs a cost when runtimeType is called
for the first time per recursive subtype.

See: https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md#runtime-semantics

Change-Id: I76d714c5e618d77f334d90862bb7d3c9b0b8d305
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130727
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-01-15 21:21:27 +00:00
Johnni Winther d08f070b28 [cfe] Add canonical way to detect the synthesized redirecting factory field
Change-Id: Ied5ffe786558856c4e63881880cbd19fa0bd6c68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131620
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-14 09:42:45 +00:00
Jacob MacDonald e4f4c74de9 remove --bazel-mappings support since it is no longer used
Change-Id: I792e4abe5d4f09780d57f4ba893559642c36f894
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130887
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2020-01-10 19:43:41 +00:00
Nate Bosch d0e36cd93f Remove isKernel argment tracking
Closes #38777

This was hardcoded to true and no longer needs to be read.

Change-Id: I1c2df0ac55776c842563f12a67d298a508156bd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130822
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2020-01-09 21:49:16 +00:00
Nate Bosch 2d82fb42ce Enforce and fix lint prefer_single_quotes
Change-Id: I7e7b18d90ae8518c700607ec383c73a0eda5a299
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130726
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2020-01-08 22:07:21 +00:00
Nate Bosch c3756794e7 Refactor arg list to use conditional elements
Change-Id: I2c95bab40ac76c3741381f5c801de0b84a102f5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130761
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-08 20:44:25 +00:00
Nate Bosch 0a728f0f08 Enable null aware lints
- Enable `prefer_null_aware_operators`, it was already clean.
- Enable `prefer_conditional_assignment` and fix one violation.

Change-Id: I73a5062d5aeedaea9a7b542db02f455111566cfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130724
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-08 20:39:50 +00:00
Dmitry Stefantsov 1eacac48cf [cfe] Make .{thisF,f}unctionType nullability-aware
Change-Id: I4a83f4db7d6412165882e4a1f08c7fded6b9ea3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130373
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2020-01-08 11:52:06 +00:00
Mark Zhou 5696cd8d09 [dartdevc] Emitting nullability wrappers for generic classes and type parameters.
We are establishing a convention that nullability wrappers will be emitted at the
call sites of 'is', 'as', and '_check' calls (when necessary). Additional wrappers
will be emitted when forward-declaring generic types at the top level - but only
around the generic parameters themselves.

For example, declaring List<int>, List<int?>, List<int>?, and List<int?>? results
in two top-level classes: ListOfInt(int) and ListOfInt$(dart.nullable(int)).

Change-Id: I2d91e170d8e1e911ad9eb70d6b4d67f1cc4cdbc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129921
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-07 18:33:35 +00:00
Nate Bosch 4be46419fa Add types to uninitialized variables in DDC
Enable and fix lint prefer_typing_uninitialied_variables

Change-Id: Ibb739b21ac8654feef01ecc2aa1c646882b0b749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130140
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-06 23:45:51 +00:00
Nicholas Shahan 98635636d7 [dartdevc] Cleanup violations of always_declare_return_types lint
This change does not enable the lint yet because there are many more violations
in the test and tool directories. I'm going to clean those up in a separate
change.

Change-Id: I8a7f9a9004d329db5ba34030cc8aa8e20d07f3ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130012
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2020-01-02 23:23:06 +00:00
Mark Zhou 3aa23f8091 [dartdevc] Removing nullability wrappers from const __proto__ fields.
Change-Id: Id56a082f8077ab16080d7ad3450075a858777527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129812
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-01-02 22:14:56 +00:00
Nate Bosch 113ff6c993 Enforce that allowInterop is used in DDC
Fixes #39074

DDC emits Dart code that can usually be called with the same semantics
as JS there is no guarantee that a function passed to JS and then
invoked successfully was wrapped with `allowInterop`. The wrapping is
always required in Dart2JS. To make DDC more strict, add interceptors
that check for the usage of `allowInterop`.

Whenever a JS interop function or setter is passed an argument which is
statically typed as a Function, but not wrapped with `allowInterop` at
the call site, wrap it with `assertInterop` which will check the
argument at call time and fail with a clear error if it was not wrapped.

Whenever a JS interop function is torn off, either at the top level or
from an instance, wrap it with a function that will also inject these
checks at runtime.

There are still holes where we can't catch the mistake:
- An argument which is statically dynamic and a Function at runtime
  won't be caught.
- A Function which is stored in a collection won't be caught.
- A JS interop definition where a getter returns a Function which takes
  a Function as an argument is not checked.
- A dynamic call through to javascript is not checked.

Changes:

- Refactor `_isJsLibrary` and add `isJsMember`, and `isAllowInterop`
  utilities to determine what needs wrapping.
- Update `assertInterop` to give a more clear error when it fails, and
  to ignore non function arguments.
- Add `tearoffInterop` to wrap a function an ensure that any function
  typed arguments are wrapped.
- Inject `assertInterop` around Function arguments passed to JS methods.
- Inject `assertInterop` around Function arguments passed to static or
  instance JS setters.
- Inject a runtime wrapper around static or instance Function tearoffs.
- Add a test covering all flavors of checks that are supported.
- Change the interop expando to an `Expando<dynamic>` in the NNBD SDK to work
  around a stricter type check. https://github.com/dart-lang/sdk/issues/39971

Potential improvements:

If the `tearoffInterop` turns out to be too heavy, we could loosen it so
that we only wrap methods if any of their argument types are statically
declared to be a Function.

Change-Id: Ibc92df5b54e1a041b4102a07b8398b774b6bd1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128462
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-01-02 20:24:26 +00:00
Mark Zhou 1f6a0c21d6 [dartdevc] Unemitting nullability modifiers for constructors and generator wrappers.
Change-Id: I5d4892cf6be814e943e6ebecde3b3156cff0bbbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129481
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2019-12-23 23:55:40 +00:00
Mark Zhou ffc17eba93 [dartdevc] Emitting is expressions correctly for NNBD-compliant ints.
Change-Id: I4ee2866ed4357926644d4300e232583bcead473d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129221
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2019-12-20 18:40:24 +00:00
Mark Zhou d85ec3c0c3 [dartdevc] Removing nullability wrappers from constructor invocations.
Change-Id: I8cf2058dd66bfa4bb1e76d16da8e4e48dcb478c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129300
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2019-12-20 18:12:40 +00:00
Nicholas Shahan c13ab9dce2 [dartdevc] Start emitting type wrappers for null safety
Legacy and nullable types will get wrapped with their respective wrappers when
compiling applications with null safety enabled.

Change-Id: I1defe4fc9d5d9b5eacf23a479178eca060ea716b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128379
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2019-12-18 00:14:34 +00:00
Johnni Winther 818ec6db92 [cfe] Implement nnbd-top-merge
+ and use nnbd-top-merge and legacy erasure in hierarchy computation

Change-Id: I4bf06ce8d3c68a9926865ebf84b24b4029828d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128065
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-12-13 17:19:59 +00:00
Nicholas Shahan e3a9dec3e6 [dartdevc] Remove dead code that handles functions in asserts
This code is causing an issue when running tests with the NNBD SDK. As I
understand it used to be possible to pass a function to assert but that feature
was removed from the language. We might as well remove it from DDC too :)

Change-Id: Ia62c653ec9d4c98694986b2c326d2b1b027b9ed9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128308
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2019-12-13 17:14:29 +00:00
Nicholas Shahan 598fba0147 [dartdevc] Actually use the libraries from the NNBD fork of the SDK
This change fixes the issues causing build failures when using the
forked NNBD SDK sources and trying to build the dartdevc_kernel_sdk
target.

The end result is a dart_sdk.js file that is known to be incorrect
(missing uses of the legacy and nullable type wrapping) but serves
as a baseline for improvement. Some tests of the runtime directly
will correctly pass.

Following changes will turn on the type wrapping and we can start
diagnosing and fixing the issues that appear.

Fixes: #38665

Change-Id: Iddcf31ef2520fa54bf7d9ae6262c2264636b9b10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127780
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2019-12-13 17:11:19 +00:00
Nicholas Shahan c561a9eacc [dartdevc] Delete the legacy version of DDC
Change-Id: I2dc3999b0b7e93252402422d662fb5da4dcca3f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127840
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2019-12-12 21:53:08 +00:00
Konstantin Shcheglov 3389b3bd32 Remove Packages from SourceFactory.
We have PackageMapUriResolver, this should be the way to resolve
all `package:xyz` URIs. We should not repeat it in SourceFactory.

Change-Id: I52d33dbf7e2d44f2c53521f6a51b0aea70507d3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128106
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-12 17:10:00 +00:00