Skip to content

Commit 307e5a6

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Include offended version number and package name in too high/low version message
Closes #48819 Change-Id: I8700ed909c916b9c656cc8bc0e34eb1dd6ef0c09 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390200 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 58cc805 commit 307e5a6

File tree

55 files changed

+315
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+315
-215
lines changed

pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart

Lines changed: 116 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11273,59 +11273,151 @@ const MessageCode messageLanguageVersionPatchContext = const MessageCode(
1127311273
);
1127411274

1127511275
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11276-
const Template<Message Function(int count, int count2)>
11277-
templateLanguageVersionTooHigh =
11278-
const Template<Message Function(int count, int count2)>(
11279-
"LanguageVersionTooHigh",
11276+
const Template<Message Function(int count, int count2, int count3, int count4)>
11277+
templateLanguageVersionTooHighExplicit = const Template<
11278+
Message Function(int count, int count2, int count3, int count4)>(
11279+
"LanguageVersionTooHighExplicit",
1128011280
problemMessageTemplate:
11281-
r"""The specified language version is too high. The highest supported language version is #count.#count2.""",
11282-
withArguments: _withArgumentsLanguageVersionTooHigh,
11281+
r"""The specified language version #count.#count2 is too high. The highest supported language version is #count3.#count4.""",
11282+
withArguments: _withArgumentsLanguageVersionTooHighExplicit,
1128311283
);
1128411284

1128511285
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11286-
const Code<Message Function(int count, int count2)> codeLanguageVersionTooHigh =
11287-
const Code<Message Function(int count, int count2)>(
11288-
"LanguageVersionTooHigh",
11286+
const Code<Message Function(int count, int count2, int count3, int count4)>
11287+
codeLanguageVersionTooHighExplicit =
11288+
const Code<Message Function(int count, int count2, int count3, int count4)>(
11289+
"LanguageVersionTooHighExplicit",
1128911290
);
1129011291

1129111292
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11292-
Message _withArgumentsLanguageVersionTooHigh(int count, int count2) {
11293+
Message _withArgumentsLanguageVersionTooHighExplicit(
11294+
int count, int count2, int count3, int count4) {
1129311295
return new Message(
11294-
codeLanguageVersionTooHigh,
11296+
codeLanguageVersionTooHighExplicit,
1129511297
problemMessage:
11296-
"""The specified language version is too high. The highest supported language version is ${count}.${count2}.""",
11298+
"""The specified language version ${count}.${count2} is too high. The highest supported language version is ${count3}.${count4}.""",
1129711299
arguments: {
1129811300
'count': count,
1129911301
'count2': count2,
11302+
'count3': count3,
11303+
'count4': count4,
1130011304
},
1130111305
);
1130211306
}
1130311307

1130411308
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11305-
const Template<Message Function(int count, int count2)>
11306-
templateLanguageVersionTooLow =
11307-
const Template<Message Function(int count, int count2)>(
11308-
"LanguageVersionTooLow",
11309+
const Template<
11310+
Message Function(
11311+
int count, int count2, String name, int count3, int count4)>
11312+
templateLanguageVersionTooHighPackage = const Template<
11313+
Message Function(
11314+
int count, int count2, String name, int count3, int count4)>(
11315+
"LanguageVersionTooHighPackage",
1130911316
problemMessageTemplate:
11310-
r"""The specified language version is too low. The lowest supported language version is #count.#count2.""",
11311-
withArguments: _withArgumentsLanguageVersionTooLow,
11317+
r"""The language version #count.#count2 specified for the package '#name' is too high. The highest supported language version is #count3.#count4.""",
11318+
withArguments: _withArgumentsLanguageVersionTooHighPackage,
1131211319
);
1131311320

1131411321
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11315-
const Code<Message Function(int count, int count2)> codeLanguageVersionTooLow =
11316-
const Code<Message Function(int count, int count2)>(
11317-
"LanguageVersionTooLow",
11322+
const Code<
11323+
Message Function(
11324+
int count, int count2, String name, int count3, int count4)>
11325+
codeLanguageVersionTooHighPackage = const Code<
11326+
Message Function(
11327+
int count, int count2, String name, int count3, int count4)>(
11328+
"LanguageVersionTooHighPackage",
11329+
);
11330+
11331+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11332+
Message _withArgumentsLanguageVersionTooHighPackage(
11333+
int count, int count2, String name, int count3, int count4) {
11334+
if (name.isEmpty) throw 'No name provided';
11335+
name = demangleMixinApplicationName(name);
11336+
return new Message(
11337+
codeLanguageVersionTooHighPackage,
11338+
problemMessage:
11339+
"""The language version ${count}.${count2} specified for the package '${name}' is too high. The highest supported language version is ${count3}.${count4}.""",
11340+
arguments: {
11341+
'count': count,
11342+
'count2': count2,
11343+
'name': name,
11344+
'count3': count3,
11345+
'count4': count4,
11346+
},
11347+
);
11348+
}
11349+
11350+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11351+
const Template<Message Function(int count, int count2, int count3, int count4)>
11352+
templateLanguageVersionTooLowExplicit = const Template<
11353+
Message Function(int count, int count2, int count3, int count4)>(
11354+
"LanguageVersionTooLowExplicit",
11355+
problemMessageTemplate:
11356+
r"""The specified language version #count.#count2 is too low. The lowest supported language version is #count3.#count4.""",
11357+
withArguments: _withArgumentsLanguageVersionTooLowExplicit,
1131811358
);
1131911359

1132011360
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11321-
Message _withArgumentsLanguageVersionTooLow(int count, int count2) {
11361+
const Code<Message Function(int count, int count2, int count3, int count4)>
11362+
codeLanguageVersionTooLowExplicit =
11363+
const Code<Message Function(int count, int count2, int count3, int count4)>(
11364+
"LanguageVersionTooLowExplicit",
11365+
);
11366+
11367+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11368+
Message _withArgumentsLanguageVersionTooLowExplicit(
11369+
int count, int count2, int count3, int count4) {
1132211370
return new Message(
11323-
codeLanguageVersionTooLow,
11371+
codeLanguageVersionTooLowExplicit,
1132411372
problemMessage:
11325-
"""The specified language version is too low. The lowest supported language version is ${count}.${count2}.""",
11373+
"""The specified language version ${count}.${count2} is too low. The lowest supported language version is ${count3}.${count4}.""",
1132611374
arguments: {
1132711375
'count': count,
1132811376
'count2': count2,
11377+
'count3': count3,
11378+
'count4': count4,
11379+
},
11380+
);
11381+
}
11382+
11383+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11384+
const Template<
11385+
Message Function(
11386+
int count, int count2, String name, int count3, int count4)>
11387+
templateLanguageVersionTooLowPackage = const Template<
11388+
Message Function(
11389+
int count, int count2, String name, int count3, int count4)>(
11390+
"LanguageVersionTooLowPackage",
11391+
problemMessageTemplate:
11392+
r"""The language version #count.#count2 specified for the package '#name' is too low. The lowest supported language version is #count3.#count4.""",
11393+
withArguments: _withArgumentsLanguageVersionTooLowPackage,
11394+
);
11395+
11396+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11397+
const Code<
11398+
Message Function(
11399+
int count, int count2, String name, int count3, int count4)>
11400+
codeLanguageVersionTooLowPackage = const Code<
11401+
Message Function(
11402+
int count, int count2, String name, int count3, int count4)>(
11403+
"LanguageVersionTooLowPackage",
11404+
);
11405+
11406+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
11407+
Message _withArgumentsLanguageVersionTooLowPackage(
11408+
int count, int count2, String name, int count3, int count4) {
11409+
if (name.isEmpty) throw 'No name provided';
11410+
name = demangleMixinApplicationName(name);
11411+
return new Message(
11412+
codeLanguageVersionTooLowPackage,
11413+
problemMessage:
11414+
"""The language version ${count}.${count2} specified for the package '${name}' is too low. The lowest supported language version is ${count3}.${count4}.""",
11415+
arguments: {
11416+
'count': count,
11417+
'count2': count2,
11418+
'name': name,
11419+
'count3': count3,
11420+
'count4': count4,
1132911421
},
1133011422
);
1133111423
}

pkg/front_end/lib/src/source/source_compilation_unit.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ class SourceCompilationUnitImpl implements SourceCompilationUnit {
351351
// If trying to set a language version that is higher than the current sdk
352352
// version it's an error.
353353
addPostponedProblem(
354-
templateLanguageVersionTooHigh.withArguments(
354+
templateLanguageVersionTooHighExplicit.withArguments(
355+
version.major,
356+
version.minor,
355357
loader.target.currentSdkVersion.major,
356358
loader.target.currentSdkVersion.minor),
357359
offset,
@@ -363,7 +365,9 @@ class SourceCompilationUnitImpl implements SourceCompilationUnit {
363365
fileUri, offset, length, packageLanguageVersion.version, true);
364366
} else if (version < loader.target.leastSupportedVersion) {
365367
addPostponedProblem(
366-
templateLanguageVersionTooLow.withArguments(
368+
templateLanguageVersionTooLowExplicit.withArguments(
369+
version.major,
370+
version.minor,
367371
loader.target.leastSupportedVersion.major,
368372
loader.target.leastSupportedVersion.minor),
369373
offset,

pkg/front_end/lib/src/source/source_loader.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,20 @@ class SourceLoader extends Loader {
550550
if (version > target.currentSdkVersion) {
551551
// Coverage-ignore-block(suite): Not run.
552552
packageLanguageVersionProblem =
553-
templateLanguageVersionTooHigh.withArguments(
553+
templateLanguageVersionTooHighPackage.withArguments(
554+
version.major,
555+
version.minor,
556+
packageForLanguageVersion.name,
554557
target.currentSdkVersion.major,
555558
target.currentSdkVersion.minor);
556559
packageLanguageVersion = new InvalidLanguageVersion(
557560
fileUri, 0, noLength, target.currentSdkVersion, false);
558561
} else if (version < target.leastSupportedVersion) {
559562
packageLanguageVersionProblem =
560-
templateLanguageVersionTooLow.withArguments(
563+
templateLanguageVersionTooLowPackage.withArguments(
564+
version.major,
565+
version.minor,
566+
packageForLanguageVersion.name,
561567
target.leastSupportedVersion.major,
562568
target.leastSupportedVersion.minor);
563569
packageLanguageVersion = new InvalidLanguageVersion(

pkg/front_end/messages.status

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,14 @@ LanguageVersionMismatchInPart/analyzerCode: Fail
708708
LanguageVersionMismatchInPart/part_wrapped_script: Fail # Part in (now) part.
709709
LanguageVersionMismatchInPatch/analyzerCode: Fail
710710
LanguageVersionMismatchInPatch/example: Fail
711-
LanguageVersionTooHigh/analyzerCode: Fail
712-
LanguageVersionTooHigh/part_wrapped_script: Fail # Content comes after "part of [...]" meaning it's not actually a language version specification.
713-
LanguageVersionTooLow/analyzerCode: Fail
714-
LanguageVersionTooLow/part_wrapped_script: Fail # Content comes after "part of [...]" meaning it's not actually a language version specification.
711+
LanguageVersionTooHighExplicit/analyzerCode: Fail
712+
LanguageVersionTooHighExplicit/part_wrapped_script: Fail # Content comes after "part of [...]" meaning it's not actually a language version specification.
713+
LanguageVersionTooHighPackage/analyzerCode: Fail
714+
LanguageVersionTooHighPackage/example: Fail
715+
LanguageVersionTooLowExplicit/analyzerCode: Fail
716+
LanguageVersionTooLowExplicit/part_wrapped_script: Fail # Content comes after "part of [...]" meaning it's not actually a language version specification.
717+
LanguageVersionTooLowPackage/analyzerCode: Fail
718+
LanguageVersionTooLowPackage/example: Fail
715719
LateDefinitelyAssignedError/analyzerCode: Fail
716720
LateDefinitelyUnassignedError/analyzerCode: Fail
717721
LibraryDirectiveNotFirst/part_wrapped_script1: Fail # Defining library name in the (now) part.

pkg/front_end/messages.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5369,16 +5369,22 @@ ExtensionTypeCombinedMemberSignatureFailed:
53695369
}
53705370
extension type C(I3 i) implements I2, I1 {}
53715371
5372-
LanguageVersionTooHigh:
5373-
problemMessage: "The specified language version is too high. The highest supported language version is #count.#count2."
5372+
LanguageVersionTooHighExplicit:
5373+
problemMessage: "The specified language version #count.#count2 is too high. The highest supported language version is #count3.#count4."
53745374
script: >
53755375
// @dart = 100.200
53765376
5377-
LanguageVersionTooLow:
5378-
problemMessage: "The specified language version is too low. The lowest supported language version is #count.#count2."
5377+
LanguageVersionTooHighPackage:
5378+
problemMessage: "The language version #count.#count2 specified for the package '#name' is too high. The highest supported language version is #count3.#count4."
5379+
5380+
LanguageVersionTooLowExplicit:
5381+
problemMessage: "The specified language version #count.#count2 is too low. The lowest supported language version is #count3.#count4."
53795382
script: >
53805383
// @dart = 2.9
53815384
5385+
LanguageVersionTooLowPackage:
5386+
problemMessage: "The language version #count.#count2 specified for the package '#name' is too low. The lowest supported language version is #count3.#count4."
5387+
53825388
LanguageVersionInvalidInDotPackages:
53835389
problemMessage: "The language version is not specified correctly in the packages file."
53845390
exampleAllowMoreCodes: true

pkg/front_end/test/language_versioning/data/library_with_bad_version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
/*error: errors=LanguageVersionTooHigh*/
5+
/*error: errors=LanguageVersionTooHighExplicit*/
66
// @dart = %TOO_HIGH_VERSION_MARKER%
77

88
// If no valid language version is specified, we default to the most recent one.

pkg/front_end/test/language_versioning/data/library_with_bad_version_before_good_version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
/*error: errors=LanguageVersionTooHigh*/
5+
/*error: errors=LanguageVersionTooHighExplicit*/
66
// @dart = %TOO_HIGH_VERSION_MARKER%
77

88
// @dart = %VERSION_MARKER1%

pkg/front_end/test/language_versioning/data/package_default_version/lib/foo4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// range of the sdk. The library stays on the .dart_tool/package_config.json
88
// specified one (%VERSION_MARKER1%) and an error is issued.
99

10-
/*error: errors=LanguageVersionTooHigh*/
10+
/*error: errors=LanguageVersionTooHighExplicit*/
1111
// @dart = %TOO_HIGH_VERSION_MARKER%
1212

1313
/*library: languageVersion=%VERSION_MARKER1%*/

pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*error: errors=LanguageVersionTooHigh*/
1+
/*error: errors=LanguageVersionTooHighPackage*/
22
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
33
// for details. All rights reserved. Use of this source code is governed by a
44
// BSD-style license that can be found in the LICENSE file.

pkg/front_end/test/language_versioning/data/package_to_high_default_version/lib/foo2.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/*error: errors=LanguageVersionTooHigh*/
1+
/*error: errors=LanguageVersionTooHighPackage*/
22
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
33
// for details. All rights reserved. Use of this source code is governed by a
44
// BSD-style license that can be found in the LICENSE file.
55

6-
/*error: errors=LanguageVersionTooHigh*/
6+
/*error: errors=LanguageVersionTooHighExplicit*/
77
// @dart = %TOO_HIGH_VERSION_MARKER%
88

99
/*library: languageVersion=%CURRENT_VERSION_MARKER%*/

0 commit comments

Comments
 (0)