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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 12038018: Disallow mixing in classes that have constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 2f5602e3715600c7205335fac71e26ea4a1fffda..5b54c63c095337507ff4cfdb7fbafa67bb3885a9 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -509,12 +509,22 @@ class ResolverTask extends CompilerTask {
error, Diagnostic.ERROR);
}
+ // Check that the mixed in class has Object as its superclass.
ClassElement mixin = mixinApplication.mixin;
if (!mixin.superclass.isObject(compiler)) {
CompilationError error = MessageKind.ILLEGAL_MIXIN_SUPERCLASS.error();
compiler.reportMessage(compiler.spanFromElement(mixin),
error, Diagnostic.ERROR);
}
+
+ // Check that the mixed in class doesn't have any constructors.
+ mixin.forEachLocalMember((Element member) {
+ if (member.isGenerativeConstructor() && !member.isSynthesized) {
+ CompilationError error = MessageKind.ILLEGAL_MIXIN_CONSTRUCTOR.error();
+ compiler.reportMessage(compiler.spanFromElement(member),
+ error, Diagnostic.ERROR);
+ }
+ });
}
void checkClassMembers(ClassElement cls) {

Powered by Google App Engine
This is Rietveld 408576698