[ddc, dart2js] readd dart:mirrors

Technically almost no user of ddc should be able to reach this compile-time error if they are using webdev (it appears a couple users do invoke it directly, though).  Project sass demonstrated that users of dart2js can notice this breaking change.

Given that we are bundling many breaking changes for null-safety on the next release, it seems like making imports to dart:mirrors a compile-time error is not strictly necessary at this time.

One idea is to change this to a compile-time error in our tools when users opt-in their libraries or when they enable strong null-safety mode.

Change-Id: I7f12657eba508e2d071dda60087a21475a303d9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139494
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2020-03-14 03:04:37 +00:00 committed by commit-bot@chromium.org
parent 5d4dc1d5c4
commit 344e149a89
7 changed files with 132 additions and 8 deletions

View file

@ -113,10 +113,14 @@ additional details see the [announcement].
`external`. Previously the external could be omitted in some cases with DDC
but doing so would cause incorrect behavior with `dart2js`.
* JS interop classes with an index operator are now static errors.
* Removed the `dart:mirrors` library from the SDK. Use of this library on the
web has been unsupported and prevented by the Dart build systems since Dart
v2.0.0. All known exception cases have been cleaned up. This change makes DDC
and dart2js now issue a compile-time error directly as well.
* All remaining support from the `dart:mirrors` library has been removed.
Use of this library on the web has been unsupported and prevented by the Dart
build systems since Dart v2.0.0. All known exception cases have been cleaned
up. This change makes DDC and dart2js now behave consistently.
The library can still be imported on web apps, but all APIs throw. In a future
breaking change release, imports to this library will likely become a
compile-time error.
[announcement]: https://github.com/dart-lang/sdk/issues/38994
@ -128,10 +132,6 @@ additional details see the [announcement].
forgiving. Corresponding type parameter bounds now only need to be mutual
subtypes rather than structurally equal up to renaming of bound type variables
and equating all top types.
* Removed the `dart:mirrors` library from the SDK. Use of this library on the
web has been unsupported and prevented by the Dart build systems since Dart
v2.0.0. All known exception cases have been cleaned up. This change makes DDC
and dart2js now issue a compile-time error directly as well.
* **Breaking Change**: Types are now normalized. See [normalization] for the
full specification. Types will now be printed in their normal form, and
mutual subtypes with the same normal form will now be considered equal.

View file

@ -24,3 +24,23 @@ ClassMirror reflectClass(Type key) => throw new UnsupportedError(_message);
@patch
TypeMirror reflectType(Type key, [List<Type> typeArguments]) =>
throw new UnsupportedError(_message);
@patch
abstract class MirrorSystem {
Map<Uri, LibraryMirror> get libraries;
IsolateMirror get isolate;
TypeMirror get dynamicType;
TypeMirror get voidType;
TypeMirror get neverType;
@patch
LibraryMirror findLibrary(Symbol libraryName) =>
throw new UnsupportedError(_message);
@patch
static String getName(Symbol symbol) => throw new UnsupportedError(_message);
@patch
static Symbol getSymbol(String name, [LibraryMirror library]) =>
throw new UnsupportedError(_message);
}

View file

@ -217,6 +217,11 @@
"uri": "math/math.dart",
"patches": "_internal/js_runtime/lib/math_patch.dart"
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"typed_data": {
"uri": "typed_data/typed_data.dart",
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@ -322,6 +327,11 @@
"uri": "math/math.dart",
"patches": "_internal/js_runtime/lib/math_patch.dart"
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"typed_data": {
"uri": "typed_data/typed_data.dart",
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@ -428,6 +438,11 @@
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
"supported": false
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"math": {
"uri": "math/math.dart",
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"

View file

@ -214,6 +214,11 @@ dart2js:
uri: "math/math.dart"
patches: "_internal/js_runtime/lib/math_patch.dart"
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
typed_data:
uri: "typed_data/typed_data.dart"
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@ -317,6 +322,11 @@ dart2js_server:
uri: "math/math.dart"
patches: "_internal/js_runtime/lib/math_patch.dart"
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
typed_data:
uri: "typed_data/typed_data.dart"
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@ -421,6 +431,11 @@ dartdevc:
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
supported: false
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
math:
uri: "math/math.dart"
patches: "_internal/js_dev_runtime/patch/math_patch.dart"

View file

@ -0,0 +1,44 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// 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.
// Patch library for dart:mirrors.
import 'dart:_js_helper' show patch;
import 'dart:mirrors';
const String _message = 'dart:mirrors is no longer supported for web apps';
@patch
MirrorSystem currentMirrorSystem() => throw new UnsupportedError(_message);
@patch
InstanceMirror reflect(dynamic reflectee) =>
throw new UnsupportedError(_message);
@patch
ClassMirror reflectClass(Type key) => throw new UnsupportedError(_message);
@patch
TypeMirror reflectType(Type key, [List<Type> typeArguments]) =>
throw new UnsupportedError(_message);
@patch
abstract class MirrorSystem {
Map<Uri, LibraryMirror> get libraries;
IsolateMirror get isolate;
TypeMirror get dynamicType;
TypeMirror get voidType;
TypeMirror get neverType;
@patch
LibraryMirror findLibrary(Symbol libraryName) =>
throw new UnsupportedError(_message);
@patch
static String getName(Symbol symbol) => throw new UnsupportedError(_message);
@patch
static Symbol getSymbol(String name, [LibraryMirror library]) =>
throw new UnsupportedError(_message);
}

View file

@ -217,6 +217,11 @@
"uri": "math/math.dart",
"patches": "_internal/js_runtime/lib/math_patch.dart"
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"typed_data": {
"uri": "typed_data/typed_data.dart",
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@ -322,6 +327,11 @@
"uri": "math/math.dart",
"patches": "_internal/js_runtime/lib/math_patch.dart"
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"typed_data": {
"uri": "typed_data/typed_data.dart",
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
@ -428,6 +438,11 @@
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
"supported": false
},
"mirrors": {
"uri": "mirrors/mirrors.dart",
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
"supported": false
},
"math": {
"uri": "math/math.dart",
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"

View file

@ -214,6 +214,11 @@ dart2js:
uri: "math/math.dart"
patches: "_internal/js_runtime/lib/math_patch.dart"
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
typed_data:
uri: "typed_data/typed_data.dart"
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@ -317,6 +322,11 @@ dart2js_server:
uri: "math/math.dart"
patches: "_internal/js_runtime/lib/math_patch.dart"
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
typed_data:
uri: "typed_data/typed_data.dart"
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
@ -421,6 +431,11 @@ dartdevc:
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
supported: false
mirrors:
uri: "mirrors/mirrors.dart"
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
supported: false
math:
uri: "math/math.dart"
patches: "_internal/js_dev_runtime/patch/math_patch.dart"