Use shared error for constructor's with return type.

Dart2js reports constructor's with return type, as long as the class is used.

R=sigmund@google.com

Review URL: https://codereview.chromium.org/1704173002 .
This commit is contained in:
Florian Loitsch 2016-02-17 23:50:41 +01:00
parent 0c86f0d58b
commit 3301bc7786
4 changed files with 14 additions and 8 deletions

View file

@ -65,4 +65,12 @@ const Map<MessageKind, MessageTemplate> TEMPLATES = const <MessageKind, MessageT
"external foo; main(){}",
]
), // Generated. Don't edit.
MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE: const MessageTemplate(
MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE,
"Constructors can't have a return type",
howToFix: "Try removing the return type.",
examples: const [
"class A { int A() {} } main() { new A(); }",
]
), // Generated. Don't edit.
};

View file

@ -1847,10 +1847,6 @@ main() {
const MessageTemplate(MessageKind.OPERATOR_NAMED_PARAMETERS,
"Operator '#{operatorName}' cannot have named parameters."),
MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE:
const MessageTemplate(MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE,
"Cannot have return type for constructor."),
MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR:
const MessageTemplate(MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR,
"Constructors can't return values.",

File diff suppressed because one or more lines are too long

View file

@ -385,18 +385,20 @@ final Map<String, Message> MESSAGES = {
]),
'CLASS_IN_CLASS': new Message(
// Dart2js currently reports this as an EXTRANEOUS_MODIFIER error.
// TODO(floitsch): make dart2js use this error instead.
id: 'DOTHQH',
category: Category.parserError,
template: "Classes can't be declared inside other classes.",
howToFix: "Try moving the class to the top-level.",
usedBy: [analyzer],
examples: const ["class A { class B {} } main() {}",]),
examples: const ["class A { class B {} } main() { new A(); }",]),
'CONSTRUCTOR_WITH_RETURN_TYPE': new Message(
id: 'VOJBWY',
category: Category.parserError,
template: "Constructors can't have a return type",
howToFix: "Try removing the return type.",
usedBy: [analyzer],
examples: const ["class A { int A() {} } main() {}",]),
usedBy: [analyzer, dart2js],
examples: const ["class A { int A() {} } main() { new A(); }",]),
};