Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: pkg/front_end/lib/src/fasta/source/source_loader.dart

Issue 2907333003: Fix performance regression for checking that retricted types are not (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/kernel/fasta_support.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/source/source_loader.dart
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 8ac15998ca36979a860781e2f94c099365076a21..dc290c1cca88e804511b3d7a9ded99b02ba8927f 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -336,6 +336,14 @@ class SourceLoader<L> extends Loader<L> {
return output;
}
+ /// Whether [library] is allowed to define classes that extend or implement
+ /// restricted types, such as `bool`, `int`, `double`, `num`, and `String`. By
+ /// default this is only allowed within the implementation of `dart:core`, but
+ /// some target implementations may need to override this to allow doing this
+ /// in other internal platform libraries.
+ bool canImplementRestrictedTypes(LibraryBuilder library) =>
+ library == coreLibrary;
+
void checkSemantics() {
List<ClassBuilder> allClasses = target.collectAllClasses();
Iterable<ClassBuilder> candidates = cyclicCandidates(allClasses);
@@ -384,11 +392,8 @@ class SourceLoader<L> extends Loader<L> {
cls.charOffset,
"'${supertype.name}' is an enum and can't be extended or "
"implemented.");
- } else if (!cls.library.uri.isScheme('dart') &&
+ } else if (!canImplementRestrictedTypes(cls.library) &&
blackListedClasses.contains(supertype)) {
- // These types are rarely extended in more than one platform library
- // but it can be on different libraries depending on the target
- // platform (e.g. dart:core for VM, dart:_interceptors for dart2js).
cls.addCompileTimeError(
cls.charOffset,
"'${supertype.name}' is restricted and can't be extended or "
« no previous file with comments | « pkg/compiler/lib/src/kernel/fasta_support.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698