Separate names of blacklisted core classes into their own file.
Change-Id: Idcb3a5f2179ef2e87e9ad17dbb38bac596218b8d
Reviewed-on: https://dart-review.googlesource.com/c/84601
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/front_end/lib/src/fasta/blacklisted_classes.dart b/pkg/front_end/lib/src/fasta/blacklisted_classes.dart
new file mode 100644
index 0000000..37dc7a7
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/blacklisted_classes.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2018, 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.
+
+// List of special classes in dart:core that can't be subclassed.
+const List<String> blacklistedCoreClasses = [
+ "bool",
+ "int",
+ "num",
+ "double",
+ "String",
+ "Null"
+];
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 9c6178f..ebf0fa1 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -35,6 +35,8 @@
import '../../base/instrumentation.dart'
show Instrumentation, InstrumentationValueLiteral;
+import '../blacklisted_classes.dart' show blacklistedCoreClasses;
+
import '../builder/builder.dart'
show
ClassBuilder,
@@ -602,14 +604,10 @@
}
}
ticker.logMs("Found cycles");
- Set<ClassBuilder> blackListedClasses = new Set<ClassBuilder>.from([
- coreLibrary["bool"],
- coreLibrary["int"],
- coreLibrary["num"],
- coreLibrary["double"],
- coreLibrary["String"],
- coreLibrary["Null"],
- ]);
+ Set<ClassBuilder> blackListedClasses = new Set<ClassBuilder>();
+ for (int i = 0; i < blacklistedCoreClasses.length; i++) {
+ blackListedClasses.add(coreLibrary[blacklistedCoreClasses[i]]);
+ }
for (ClassBuilder cls in classes) {
if (cls.library.loader != this) continue;
Set<ClassBuilder> directSupertypes = new Set<ClassBuilder>();