Skip to content

Commit 579a23d

Browse files
Remove deprecated_addError.
[email protected] Review-Url: https://codereview.chromium.org/2982673002 .
1 parent 959470b commit 579a23d

File tree

3 files changed

+67
-23
lines changed

3 files changed

+67
-23
lines changed

pkg/front_end/lib/src/fasta/fasta_codes_generated.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,24 @@ const MessageCode messageConflictsWithTypeVariableCause = const MessageCode(
281281
"ConflictsWithTypeVariableCause",
282282
message: r"""This is the type variable.""");
283283

284+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
285+
const Code<Null> codeConstConstructorNonFinalField =
286+
messageConstConstructorNonFinalField;
287+
288+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
289+
const MessageCode messageConstConstructorNonFinalField = const MessageCode(
290+
"ConstConstructorNonFinalField",
291+
message: r"""Constructor is marked 'const' so all fields must be final.""");
292+
293+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
294+
const Code<Null> codeConstConstructorNonFinalFieldCause =
295+
messageConstConstructorNonFinalFieldCause;
296+
297+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
298+
const MessageCode messageConstConstructorNonFinalFieldCause = const MessageCode(
299+
"ConstConstructorNonFinalFieldCause",
300+
message: r"""Field isn't final, but constructor is 'const'.""");
301+
284302
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
285303
const Code<Null> codeConstConstructorWithBody = messageConstConstructorWithBody;
286304

@@ -2295,6 +2313,32 @@ const MessageCode messageSuperNullAware = const MessageCode("SuperNullAware",
22952313
message: r"""'super' can't be null.""",
22962314
tip: r"""Try replacing '?.' with '.'""");
22972315

2316+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
2317+
const Template<
2318+
Message Function(
2319+
String
2320+
name)> templateSuperclassHasNoDefaultConstructor = const Template<
2321+
Message Function(String name)>(
2322+
messageTemplate:
2323+
r"""The superclass, '#name', has no unnamed constructor that takes no arguments.""",
2324+
withArguments: _withArgumentsSuperclassHasNoDefaultConstructor);
2325+
2326+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
2327+
const Code<Message Function(String name)>
2328+
codeSuperclassHasNoDefaultConstructor =
2329+
const Code<Message Function(String name)>(
2330+
"SuperclassHasNoDefaultConstructor",
2331+
templateSuperclassHasNoDefaultConstructor,
2332+
);
2333+
2334+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
2335+
Message _withArgumentsSuperclassHasNoDefaultConstructor(String name) {
2336+
return new Message(codeSuperclassHasNoDefaultConstructor,
2337+
message:
2338+
"""The superclass, '$name', has no unnamed constructor that takes no arguments.""",
2339+
arguments: {'name': name});
2340+
}
2341+
22982342
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
22992343
const Template<Message Function(String name)> templateSuperclassHasNoGetter =
23002344
const Template<Message Function(String name)>(

pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ import '../deprecated_problems.dart'
5353

5454
import '../dill/dill_target.dart' show DillTarget;
5555

56-
import '../messages.dart' show LocatedMessage;
56+
import '../messages.dart'
57+
show
58+
LocatedMessage,
59+
messageConstConstructorNonFinalField,
60+
messageConstConstructorNonFinalFieldCause,
61+
templateSuperclassHasNoDefaultConstructor;
5762

5863
import '../problems.dart' show unhandled;
5964

@@ -117,15 +122,6 @@ class KernelTarget extends TargetImplementation {
117122
loader = createLoader();
118123
}
119124

120-
void deprecated_addError(file, int charOffset, String message) {
121-
Uri uri = file is String ? Uri.parse(file) : file;
122-
deprecated_InputError error =
123-
new deprecated_InputError(uri, charOffset, message);
124-
String formatterMessage = error.deprecated_format();
125-
print(formatterMessage);
126-
errors.add(formatterMessage);
127-
}
128-
129125
SourceLoader<Library> createLoader() =>
130126
new SourceLoader<Library>(fileSystem, this);
131127

@@ -556,11 +552,10 @@ class KernelTarget extends TargetImplementation {
556552
superTarget ??= defaultSuperConstructor(cls);
557553
Initializer initializer;
558554
if (superTarget == null) {
559-
deprecated_addError(
560-
constructor.enclosingClass.fileUri,
561-
constructor.fileOffset,
562-
"${cls.superclass.name} has no constructor that takes no"
563-
" arguments.");
555+
builder.addCompileTimeError(
556+
templateSuperclassHasNoDefaultConstructor
557+
.withArguments(cls.superclass.name),
558+
constructor.fileOffset);
564559
initializer = new InvalidInitializer();
565560
} else {
566561
initializer =
@@ -584,15 +579,11 @@ class KernelTarget extends TargetImplementation {
584579
}
585580
fieldInitializers[constructor] = myFieldInitializers;
586581
if (constructor.isConst && nonFinalFields.isNotEmpty) {
587-
deprecated_addError(
588-
constructor.enclosingClass.fileUri,
589-
constructor.fileOffset,
590-
"Constructor is marked 'const' so all fields must be final.");
582+
builder.addCompileTimeError(
583+
messageConstConstructorNonFinalField, constructor.fileOffset);
591584
for (Field field in nonFinalFields) {
592-
deprecated_addError(
593-
constructor.enclosingClass.fileUri,
594-
field.fileOffset,
595-
"Field isn't final, but constructor is 'const'.");
585+
builder.addCompileTimeError(
586+
messageConstConstructorNonFinalFieldCause, field.fileOffset);
596587
}
597588
nonFinalFields.clear();
598589
}

pkg/front_end/messages.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,3 +831,12 @@ SuperclassHasNoSetter:
831831

832832
SuperclassHasNoMethod:
833833
template: "Superclass has no method named '#name'."
834+
835+
SuperclassHasNoDefaultConstructor:
836+
template: "The superclass, '#name', has no unnamed constructor that takes no arguments."
837+
838+
ConstConstructorNonFinalField:
839+
template: "Constructor is marked 'const' so all fields must be final."
840+
841+
ConstConstructorNonFinalFieldCause:
842+
template: "Field isn't final, but constructor is 'const'."

0 commit comments

Comments
 (0)