From 166edab750a72e55cd1aaaebe476619061d4c1ac Mon Sep 17 00:00:00 2001 From: Joshua Litt Date: Thu, 13 Feb 2020 18:37:38 +0000 Subject: [PATCH] [dart2js] Migrate developer patch file to nnbd. Note: This is mostly just the DDC developer patch file. Change-Id: I98277304b2fbe8fa939dc7e6fb4bd9e0c199b2b0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135535 Commit-Queue: Joshua Litt Reviewed-by: Sigmund Cherem --- .../tool/dart2js_nnbd_sdk_error_golden.txt | 1 + .../js_runtime/lib/developer_patch.dart | 35 ++++++++----------- sdk_nnbd/lib/dart2js_migration_libraries.json | 4 +-- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt index a5090c46723..20d4353e679 100644 --- a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt @@ -1,3 +1,4 @@ +ERROR|COMPILE_TIME_ERROR|CONST_EVAL_THROWS_EXCEPTION|lib/developer/developer.dart|522|5|73|Evaluation of this constant expression throws an exception. ERROR|COMPILE_TIME_ERROR|EXPORT_LEGACY_SYMBOL|lib/html/dart2js/html_dart2js.dart|70|8|18|The symbol 'promiseToFuture' is defined in a legacy library, and can't be re-exported from a non-nullable by default library. ERROR|COMPILE_TIME_ERROR|EXPORT_LEGACY_SYMBOL|lib/html/html_common/html_common_dart2js.dart|19|8|14|The symbol 'promiseToFuture' is defined in a legacy library, and can't be re-exported from a non-nullable by default library. ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|1639|7|5|Superinterfaces don't have a valid override for '&': int.& (int* Function(int*)*), JSNumber.& (num Function(num)). diff --git a/sdk_nnbd/lib/_internal/js_runtime/lib/developer_patch.dart b/sdk_nnbd/lib/_internal/js_runtime/lib/developer_patch.dart index 079fae8f44b..aff3f5572bb 100644 --- a/sdk_nnbd/lib/_internal/js_runtime/lib/developer_patch.dart +++ b/sdk_nnbd/lib/_internal/js_runtime/lib/developer_patch.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart = 2.5 - // Patch file for dart:developer library. import 'dart:_js_helper' show patch, ForceInline; @@ -13,7 +11,7 @@ import 'dart:isolate'; @patch @pragma('dart2js:tryInline') -bool debugger({bool when: true, String message}) { +bool debugger({bool when = true, String? message}) { if (when) { JS('', 'debugger'); } @@ -21,26 +19,26 @@ bool debugger({bool when: true, String message}) { } @patch -Object inspect(Object object) { +Object? inspect(Object? object) { return object; } @patch void log(String message, - {DateTime time, - int sequenceNumber, - int level: 0, - String name: '', - Zone zone, - Object error, - StackTrace stackTrace}) { + {DateTime? time, + int? sequenceNumber, + int level = 0, + String name = '', + Zone? zone, + Object? error, + StackTrace? stackTrace}) { // TODO. } -final _extensions = new Map(); +final _extensions = {}; @patch -ServiceExtensionHandler _lookupExtension(String method) { +ServiceExtensionHandler? _lookupExtension(String method) { return _extensions[method]; } @@ -110,7 +108,7 @@ void _webServerControl(SendPort sendPort, bool enable) { } @patch -String _getIsolateIDFromSendPort(SendPort sendPort) { +String? _getIsolateIDFromSendPort(SendPort sendPort) { return null; } @@ -124,7 +122,7 @@ class UserTag { } class _FakeUserTag implements UserTag { - static Map _instances = {}; + static final _instances = {}; _FakeUserTag.real(this.label); @@ -136,13 +134,10 @@ class _FakeUserTag implements UserTag { } // Throw an exception if we've reached the maximum number of user tags. if (_instances.length == UserTag.MAX_USER_TAGS) { - throw new UnsupportedError( + throw UnsupportedError( 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.'); } - // Create a new instance and add it to the instance map. - var instance = new _FakeUserTag.real(label); - _instances[label] = instance; - return instance; + return _instances[label] = _FakeUserTag.real(label); } final String label; diff --git a/sdk_nnbd/lib/dart2js_migration_libraries.json b/sdk_nnbd/lib/dart2js_migration_libraries.json index 629c23216b1..25c427d7ba6 100644 --- a/sdk_nnbd/lib/dart2js_migration_libraries.json +++ b/sdk_nnbd/lib/dart2js_migration_libraries.json @@ -20,8 +20,8 @@ "patches": "../../sdk/lib/_internal/js_runtime/lib/core_patch.dart" }, "developer": { - "uri": "../../sdk/lib/developer/developer.dart", - "patches": "../../sdk/lib/_internal/js_runtime/lib/developer_patch.dart" + "uri": "developer/developer.dart", + "patches": "_internal/js_runtime/lib/developer_patch.dart" }, "html": { "uri": "html/dart2js/html_dart2js.dart"