|
4 | 4 |
|
5 | 5 | // ignore_for_file: deprecated_member_use until analyzer 7 support is dropped.
|
6 | 6 |
|
7 |
| -import 'dart:mirrors' hide SourceLocation; |
8 |
| - |
9 | 7 | import 'package:analyzer/dart/analysis/results.dart';
|
10 | 8 | import 'package:analyzer/dart/ast/ast.dart';
|
11 | 9 | import 'package:analyzer/dart/constant/value.dart';
|
@@ -34,20 +32,6 @@ abstract class TypeChecker {
|
34 | 32 | /// ```
|
35 | 33 | const factory TypeChecker.any(Iterable<TypeChecker> checkers) = _AnyChecker;
|
36 | 34 |
|
37 |
| - /// Create a new [TypeChecker] backed by a runtime [type]. |
38 |
| - /// |
39 |
| - /// This implementation uses `dart:mirrors` (runtime reflection). |
40 |
| - @Deprecated(''' |
41 |
| -Will be removed in 4.0.0 to drop `dart:mirrors` dependency. |
42 |
| -
|
43 |
| -Recommended: replace `fromRuntime(Foo)` with |
44 |
| -`typeNamed(Foo, inPackage: 'foo_package')`. This is a slighly weaker check than |
45 |
| -`fromRuntime(Foo)` as it matches any annotation named `Foo` in |
46 |
| -`package:foo_package`. |
47 |
| -
|
48 |
| -If you need an exact match, use `fromUrl`.''') |
49 |
| - const factory TypeChecker.fromRuntime(Type type) = _MirrorTypeChecker; |
50 |
| - |
51 | 35 | /// Create a new [TypeChecker] for types matching the name of [type].
|
52 | 36 | ///
|
53 | 37 | /// Optionally, also pass [inPackage] to restrict to a specific package by
|
@@ -267,29 +251,6 @@ class _LibraryTypeChecker extends TypeChecker {
|
267 | 251 | String toString() => urlOfElement(_type.element3!);
|
268 | 252 | }
|
269 | 253 |
|
270 |
| -// Checks a runtime type against a static type. |
271 |
| -class _MirrorTypeChecker extends TypeChecker { |
272 |
| - static Uri _uriOf(ClassMirror mirror) => normalizeUrl( |
273 |
| - (mirror.owner as LibraryMirror).uri, |
274 |
| - ).replace(fragment: MirrorSystem.getName(mirror.simpleName)); |
275 |
| - |
276 |
| - // Precomputed type checker for types that already have been used. |
277 |
| - static final _cache = Expando<TypeChecker>(); |
278 |
| - |
279 |
| - final Type _type; |
280 |
| - |
281 |
| - const _MirrorTypeChecker(this._type) : super._(); |
282 |
| - |
283 |
| - TypeChecker get _computed => |
284 |
| - _cache[this] ??= TypeChecker.fromUrl(_uriOf(reflectClass(_type))); |
285 |
| - |
286 |
| - @override |
287 |
| - bool isExactly(Element2 element) => _computed.isExactly(element); |
288 |
| - |
289 |
| - @override |
290 |
| - String toString() => _computed.toString(); |
291 |
| -} |
292 |
| - |
293 | 254 | // Checks a runtime type name and optional package against a static type.
|
294 | 255 | class _NameTypeChecker extends TypeChecker {
|
295 | 256 | final Type _type;
|
|
0 commit comments