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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 1638923002: Compile-time error if mixing class has a factory (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | tests/language/language_analyzer2.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 184772653046a9864fa61350381d2103eb188b76..67b3683c453ca9557eef2892b74e9aaf03e32e3a 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -2210,12 +2210,23 @@ void ClassFinalizer::ApplyMixinMembers(const Class& cls) {
const intptr_t num_functions = functions.Length();
for (intptr_t i = 0; i < num_functions; i++) {
func ^= functions.At(i);
- if (func.IsGenerativeConstructor()) {
+ if (func.IsFactory() || func.IsGenerativeConstructor()) {
// A mixin class must not have explicit constructors.
if (!func.IsImplicitConstructor()) {
- ReportError(cls, cls.token_pos(),
- "mixin class '%s' must not have constructors\n",
- String::Handle(zone, mixin_cls.Name()).ToCString());
+ const char* ctr_kind = func.IsFactory() ? "factory" : "constructor";
+ const Script& script = Script::Handle(cls.script());
+ const Error& error = Error::Handle(
+ LanguageError::NewFormatted(Error::Handle(),
+ script, func.token_pos(), Report::AtLocation,
+ Report::kError, Heap::kNew,
+ "%s '%s' is illegal in mixin class %s",
+ ctr_kind,
+ String::Handle(func.PrettyName()).ToCString(),
+ String::Handle(zone, mixin_cls.Name()).ToCString()));
+
+ ReportErrors(error, cls, cls.token_pos(),
+ "mixin class '%s' must not have constructors",
+ String::Handle(zone, mixin_cls.Name()).ToCString());
}
continue; // Skip the implicit constructor.
}
« no previous file with comments | « no previous file | tests/language/language_analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698