[web] remove mirrors patch for web compilers.

This makes both compilers report a compile-time error when importing dart:mirrors.

Change-Id: I23360b87ee31fba36fe7c111cee1987aa2d50638
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154622
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2020-07-16 00:12:22 +00:00 committed by commit-bot@chromium.org
parent 6a201a7789
commit c632a629ff
6 changed files with 18 additions and 88 deletions

View file

@ -58,6 +58,18 @@
[#41653]: https://github.com/dart-lang/sdk/issues/41653
#### `dart:mirrors`
* **Breaking Change** [#42714][]: web compilers (dart2js and DDC) now produce
a compile-time error if `dart:mirrors` is imported.
Most projects should not be affected. Since 2.0.0 this library was
unsupported and produced runtime errors on all its APIs. Since then several
tools already reject code that use `dart:mirrors` including webdev and
flutter tools, we expect few projects to run into this problem.
[#42714]: https://github.com/dart-lang/sdk/issues/42714
### Tools
#### dartfmt

View file

@ -1,38 +0,0 @@
// 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 {
@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

@ -221,11 +221,6 @@
"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"
@ -334,11 +329,6 @@
"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"
@ -448,11 +438,6 @@
"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

@ -218,11 +218,6 @@ 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"
@ -329,11 +324,6 @@ 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"
@ -441,11 +431,6 @@ 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

@ -2,16 +2,9 @@
// 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:mirrors' provides no functionality in dart-web, but can be imported and
// all APIs throw.
import 'dart:mirrors';
import 'package:expect/expect.dart';
// 'dart:mirrors' can no longer be imported, doing so produces a static error.
import 'dart:mirrors'; //# 01: compile-time error
main() {
Expect.throws<UnsupportedError>(() => currentMirrorSystem());
Expect.throws<UnsupportedError>(() => reflect(main));
Expect.throws<UnsupportedError>(() => reflectClass(Object));
Expect.throws<UnsupportedError>(() => reflectType(Object));
Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
reflect(main); //# 01: continued
}

View file

@ -2,16 +2,9 @@
// 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:mirrors' provides no functionality in dart-web, but can be imported and
// all APIs throw.
import 'dart:mirrors';
import 'package:expect/expect.dart';
// 'dart:mirrors' can no longer be imported, doing so produces a static error.
import 'dart:mirrors'; //# 01: compile-time error
main() {
Expect.throws<UnsupportedError>(() => currentMirrorSystem());
Expect.throws<UnsupportedError>(() => reflect(main));
Expect.throws<UnsupportedError>(() => reflectClass(Object));
Expect.throws<UnsupportedError>(() => reflectType(Object));
Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
reflect(main); //# 01: continued
}