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

Unified Diff: runtime/vm/parser.cc

Issue 2673423003: Improve error message when super constructor is invalid (Closed)
Patch Set: Created 3 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 38ca833f6944aec018379292924f52eeafd39bce..b4153c3eeddffc5b413d56c8991e5272413a1bd5 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -2666,6 +2666,11 @@ StaticCallNode* Parser::GenerateSuperConstructorCall(
const Function& super_ctor =
Function::ZoneHandle(Z, super_class.LookupConstructor(super_ctor_name));
if (super_ctor.IsNull()) {
+ if (super_class.LookupFactory(super_ctor_name) != Function::null()) {
+ ReportError(supercall_pos,
+ "illegal implicit call to factory '%s()' in super class",
+ String::Handle(Z, super_class.Name()).ToCString());
+ }
ReportError(supercall_pos,
"unresolved implicit call to super constructor '%s()'",
String::Handle(Z, super_class.Name()).ToCString());
@@ -2717,6 +2722,12 @@ StaticCallNode* Parser::ParseSuperInitializer(const Class& cls,
const Function& super_ctor =
Function::ZoneHandle(Z, super_class.LookupConstructor(ctor_name));
if (super_ctor.IsNull()) {
+ if (super_class.LookupFactory(ctor_name) != Function::null()) {
+ ReportError(supercall_pos,
+ "super class constructor '%s' "
+ "must not be a factory constructor",
+ ctor_name.ToCString());
+ }
ReportError(supercall_pos, "super class constructor '%s' not found",
ctor_name.ToCString());
}
@@ -3102,6 +3113,11 @@ void Parser::ParseConstructorRedirection(const Class& cls,
const Function& redirect_ctor =
Function::ZoneHandle(Z, cls.LookupConstructor(ctor_name));
if (redirect_ctor.IsNull()) {
+ if (cls.LookupFactory(ctor_name) != Function::null()) {
+ ReportError(
+ call_pos, "redirection constructor '%s' must not be a factory",
+ String::Handle(Z, redirect_ctor.UserVisibleName()).ToCString());
+ }
ReportError(call_pos, "constructor '%s' not found",
String::Handle(Z, redirect_ctor.UserVisibleName()).ToCString());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698