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

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

Issue 2862223002: Rewrite mixin application handling in Fasta. (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
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 806c279da5e7fde497988b88c523deb60c360465..99adbac79ad72f3144fe53984c1d178b5a3cbcdb 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -23,7 +23,13 @@ import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
import 'package:kernel/core_types.dart' show CoreTypes;
import '../builder/builder.dart'
- show Builder, ClassBuilder, EnumBuilder, LibraryBuilder;
+ show
+ Builder,
+ ClassBuilder,
+ EnumBuilder,
+ LibraryBuilder,
+ NamedTypeBuilder,
+ TypeBuilder;
import '../compiler_context.dart' show CompilerContext;
@@ -336,10 +342,12 @@ class SourceLoader<L> extends Loader<L> {
reported.add(cls);
}
}
+ String involvedString =
+ involved.map((c) => c.fullNameForErrors).join("', '");
cls.addCompileTimeError(
cls.charOffset,
- "'${cls.name}' is a supertype of "
- "itself via '${involved.map((c) => c.name).join(' ')}'.");
+ "'${cls.fullNameForErrors}' is a supertype of itself via "
+ "'$involvedString'.");
}
});
ticker.logMs("Found cycles");
@@ -351,6 +359,7 @@ class SourceLoader<L> extends Loader<L> {
coreLibrary["String"],
]);
for (ClassBuilder cls in allClasses) {
+ if (cls.library.loader != this) continue;
Set<ClassBuilder> directSupertypes = new Set<ClassBuilder>();
target.addDirectSupertype(cls, directSupertypes);
for (ClassBuilder supertype in directSupertypes) {
@@ -367,6 +376,32 @@ class SourceLoader<L> extends Loader<L> {
"implemented.");
}
}
+ TypeBuilder mixedInType = cls.mixedInType;
+ if (mixedInType != null) {
+ bool isClassBuilder = false;
+ if (mixedInType is NamedTypeBuilder) {
+ var builder = mixedInType.builder;
+ if (builder is ClassBuilder) {
+ isClassBuilder = true;
+ for (Builder constructory in builder.constructors.local.values) {
+ if (constructory.isConstructor && !constructory.isSynthetic) {
+ cls.addCompileTimeError(
+ cls.charOffset,
+ "Can't use '${builder.fullNameForErrors}' as a mixin "
+ "because it has constructors.");
+ builder.addCompileTimeError(
+ constructory.charOffset,
+ "This constructor prevents using "
+ "'${builder.fullNameForErrors}' as a mixin.");
+ }
+ }
+ }
+ }
+ if (!isClassBuilder) {
+ cls.addCompileTimeError(cls.charOffset,
+ "The type '${mixedInType.fullNameForErrors}' can't be mixed in.");
+ }
+ }
}
ticker.logMs("Checked restricted supertypes");
}

Powered by Google App Engine
This is Rietveld 408576698