mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[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:
parent
5d4dc1d5c4
commit
344e149a89
7 changed files with 132 additions and 8 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -113,10 +113,14 @@ additional details see the [announcement].
|
||||||
`external`. Previously the external could be omitted in some cases with DDC
|
`external`. Previously the external could be omitted in some cases with DDC
|
||||||
but doing so would cause incorrect behavior with `dart2js`.
|
but doing so would cause incorrect behavior with `dart2js`.
|
||||||
* JS interop classes with an index operator are now static errors.
|
* 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
|
* All remaining support from the `dart:mirrors` library has been removed.
|
||||||
web has been unsupported and prevented by the Dart build systems since Dart
|
Use of this library on the web has been unsupported and prevented by the Dart
|
||||||
v2.0.0. All known exception cases have been cleaned up. This change makes DDC
|
build systems since Dart v2.0.0. All known exception cases have been cleaned
|
||||||
and dart2js now issue a compile-time error directly as well.
|
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
|
[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
|
forgiving. Corresponding type parameter bounds now only need to be mutual
|
||||||
subtypes rather than structurally equal up to renaming of bound type variables
|
subtypes rather than structurally equal up to renaming of bound type variables
|
||||||
and equating all top types.
|
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
|
* **Breaking Change**: Types are now normalized. See [normalization] for the
|
||||||
full specification. Types will now be printed in their normal form, and
|
full specification. Types will now be printed in their normal form, and
|
||||||
mutual subtypes with the same normal form will now be considered equal.
|
mutual subtypes with the same normal form will now be considered equal.
|
||||||
|
|
|
@ -24,3 +24,23 @@ ClassMirror reflectClass(Type key) => throw new UnsupportedError(_message);
|
||||||
@patch
|
@patch
|
||||||
TypeMirror reflectType(Type key, [List<Type> typeArguments]) =>
|
TypeMirror reflectType(Type key, [List<Type> typeArguments]) =>
|
||||||
throw new UnsupportedError(_message);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -217,6 +217,11 @@
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_runtime/lib/math_patch.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": {
|
"typed_data": {
|
||||||
"uri": "typed_data/typed_data.dart",
|
"uri": "typed_data/typed_data.dart",
|
||||||
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -322,6 +327,11 @@
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_runtime/lib/math_patch.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": {
|
"typed_data": {
|
||||||
"uri": "typed_data/typed_data.dart",
|
"uri": "typed_data/typed_data.dart",
|
||||||
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -428,6 +438,11 @@
|
||||||
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
|
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
|
||||||
"supported": false
|
"supported": false
|
||||||
},
|
},
|
||||||
|
"mirrors": {
|
||||||
|
"uri": "mirrors/mirrors.dart",
|
||||||
|
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
|
||||||
|
"supported": false
|
||||||
|
},
|
||||||
"math": {
|
"math": {
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"
|
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"
|
||||||
|
|
|
@ -214,6 +214,11 @@ dart2js:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_runtime/lib/math_patch.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:
|
typed_data:
|
||||||
uri: "typed_data/typed_data.dart"
|
uri: "typed_data/typed_data.dart"
|
||||||
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -317,6 +322,11 @@ dart2js_server:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_runtime/lib/math_patch.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:
|
typed_data:
|
||||||
uri: "typed_data/typed_data.dart"
|
uri: "typed_data/typed_data.dart"
|
||||||
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -421,6 +431,11 @@ dartdevc:
|
||||||
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
|
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
|
||||||
supported: false
|
supported: false
|
||||||
|
|
||||||
|
mirrors:
|
||||||
|
uri: "mirrors/mirrors.dart"
|
||||||
|
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
|
||||||
|
supported: false
|
||||||
|
|
||||||
math:
|
math:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_dev_runtime/patch/math_patch.dart"
|
patches: "_internal/js_dev_runtime/patch/math_patch.dart"
|
||||||
|
|
44
sdk_nnbd/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
Normal file
44
sdk_nnbd/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
Normal 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);
|
||||||
|
}
|
|
@ -217,6 +217,11 @@
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_runtime/lib/math_patch.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": {
|
"typed_data": {
|
||||||
"uri": "typed_data/typed_data.dart",
|
"uri": "typed_data/typed_data.dart",
|
||||||
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -322,6 +327,11 @@
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_runtime/lib/math_patch.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": {
|
"typed_data": {
|
||||||
"uri": "typed_data/typed_data.dart",
|
"uri": "typed_data/typed_data.dart",
|
||||||
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
"patches": "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -428,6 +438,11 @@
|
||||||
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
|
"patches": "_internal/js_dev_runtime/patch/isolate_patch.dart",
|
||||||
"supported": false
|
"supported": false
|
||||||
},
|
},
|
||||||
|
"mirrors": {
|
||||||
|
"uri": "mirrors/mirrors.dart",
|
||||||
|
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
|
||||||
|
"supported": false
|
||||||
|
},
|
||||||
"math": {
|
"math": {
|
||||||
"uri": "math/math.dart",
|
"uri": "math/math.dart",
|
||||||
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"
|
"patches": "_internal/js_dev_runtime/patch/math_patch.dart"
|
||||||
|
|
|
@ -214,6 +214,11 @@ dart2js:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_runtime/lib/math_patch.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:
|
typed_data:
|
||||||
uri: "typed_data/typed_data.dart"
|
uri: "typed_data/typed_data.dart"
|
||||||
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -317,6 +322,11 @@ dart2js_server:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_runtime/lib/math_patch.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:
|
typed_data:
|
||||||
uri: "typed_data/typed_data.dart"
|
uri: "typed_data/typed_data.dart"
|
||||||
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||||
|
@ -421,6 +431,11 @@ dartdevc:
|
||||||
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
|
patches: "_internal/js_dev_runtime/patch/isolate_patch.dart"
|
||||||
supported: false
|
supported: false
|
||||||
|
|
||||||
|
mirrors:
|
||||||
|
uri: "mirrors/mirrors.dart"
|
||||||
|
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
|
||||||
|
supported: false
|
||||||
|
|
||||||
math:
|
math:
|
||||||
uri: "math/math.dart"
|
uri: "math/math.dart"
|
||||||
patches: "_internal/js_dev_runtime/patch/math_patch.dart"
|
patches: "_internal/js_dev_runtime/patch/math_patch.dart"
|
||||||
|
|
Loading…
Reference in a new issue