Skip to content

Commit 1db9013

Browse files
authored
Switch special class definition to const (#2506)
1 parent d58b6d5 commit 1db9013

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/src/special_elements.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ class _SpecialClassDefinition {
4646
/// If true, require this element to exist in the packageGraph when
4747
/// calling the [SpecialClasses] constructor.
4848
final bool required;
49-
_SpecialClassDefinition(
49+
50+
const _SpecialClassDefinition(
5051
this.specialClass, this.name, this.libraryName, this.specialFileUri,
5152
{this.required = true, this.packageName = 'Dart'});
5253

53-
/// Get the filename for the Dart Library where this [specialClass] is
54-
/// declared.
55-
String getSpecialFilename(DartSdk sdk) =>
54+
/// Get the filename for the Dart Library where this [ModelElement]
55+
/// is declared, or `null` if its URI does not denote a library in
56+
/// the specified SDK.
57+
String /*?*/ getSpecialFilename(DartSdk sdk) =>
5658
sdk.mapDartUri(specialFileUri)?.fullName;
5759

5860
bool matchesClass(Class modelClass) {
@@ -65,7 +67,7 @@ class _SpecialClassDefinition {
6567
/// All special classes we need to find here, indexed by class name.
6668
/// The index is a shortcut to reduce processing time for determining if
6769
/// a class might be "special".
68-
final Map<String, _SpecialClassDefinition> _specialClassDefinitions = {
70+
const Map<String, _SpecialClassDefinition> _specialClassDefinitions = {
6971
'Object': _SpecialClassDefinition(
7072
SpecialClass.object, 'Object', 'dart.core', 'dart:core'),
7173
'Interceptor': _SpecialClassDefinition(SpecialClass.interceptor,

0 commit comments

Comments
 (0)