Skip to content

Commit 64fd513

Browse files
johnniwintherCommit Queue
authored and
Commit Queue
committed
[3.0 alpha] Remove error for use of the List default constructor
Contributes to #49529 Change-Id: I65d147aa8f5f692df00663f5fac024351da7aaa7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272161 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Jens Johansen <[email protected]>
1 parent 56e581a commit 64fd513

14 files changed

+0
-251
lines changed

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

-10
Original file line numberDiff line numberDiff line change
@@ -2218,16 +2218,6 @@ const MessageCode messageDeclaredMemberConflictsWithOverriddenMembersCause =
22182218
severity: Severity.context,
22192219
problemMessage: r"""This is one of the overridden members.""");
22202220

2221-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
2222-
const Code<Null> codeDefaultListConstructorError =
2223-
messageDefaultListConstructorError;
2224-
2225-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
2226-
const MessageCode messageDefaultListConstructorError = const MessageCode(
2227-
"DefaultListConstructorError",
2228-
problemMessage: r"""Can't use the default List constructor.""",
2229-
correctionMessage: r"""Try using List.filled instead.""");
2230-
22312221
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
22322222
const Template<Message Function(String name)>
22332223
templateDefaultValueInRedirectingFactoryConstructor =

pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart

-19
Original file line numberDiff line numberDiff line change
@@ -1183,12 +1183,6 @@ class InferenceVisitorImpl extends InferenceVisitorBase
11831183
node, typeSchemaEnvironment, helper.uri,
11841184
inferred: true);
11851185
}
1186-
if (isNonNullableByDefault) {
1187-
if (node.target == coreTypes.listDefaultConstructor) {
1188-
resultNode = helper.wrapInProblem(node,
1189-
messageDefaultListConstructorError, node.fileOffset, noLength);
1190-
}
1191-
}
11921186
return new ExpressionInferenceResult(
11931187
result.inferredType, result.applyResult(resultNode));
11941188
}
@@ -1244,13 +1238,6 @@ class InferenceVisitorImpl extends InferenceVisitorBase
12441238
node.hasBeenInferred = true;
12451239
Expression resultNode = node;
12461240

1247-
if (isNonNullableByDefault) {
1248-
if (node.target == coreTypes.listDefaultConstructor) {
1249-
resultNode = helper.wrapInProblem(node,
1250-
messageDefaultListConstructorError, node.fileOffset, noLength);
1251-
}
1252-
}
1253-
12541241
return new ExpressionInferenceResult(
12551242
result.inferredType, result.applyResult(resultNode));
12561243
}
@@ -1306,12 +1293,6 @@ class InferenceVisitorImpl extends InferenceVisitorBase
13061293
isConst: node.isConst, staticTarget: node.target);
13071294
node.hasBeenInferred = true;
13081295
Expression resultNode = node;
1309-
if (isNonNullableByDefault) {
1310-
if (node.target == coreTypes.listDefaultConstructor) {
1311-
resultNode = helper.wrapInProblem(node,
1312-
messageDefaultListConstructorError, node.fileOffset, noLength);
1313-
}
1314-
}
13151296
return new ExpressionInferenceResult(
13161297
result.inferredType, result.applyResult(resultNode));
13171298
}

pkg/front_end/messages.status

-4
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ CyclicClassHierarchy/script2: Fail # We report an error for each class involved
181181
CyclicRedirectingFactoryConstructors/part_wrapped_script: Fail # Error is reported for each factory involved in the cycle.
182182
CyclicRedirectingFactoryConstructors/script: Fail # Error is reported for each factory involved in the cycle.
183183
CyclicTypedef/example: Fail
184-
DefaultListConstructorError/analyzerCode: Fail
185-
DefaultListConstructorError/example: Fail
186-
DefaultListConstructorWarning/analyzerCode: Fail
187-
DefaultListConstructorWarning/example: Fail
188184
DeferredAfterPrefix/example: Fail
189185
DeferredExtensionImport/analyzerCode: Fail
190186
DeferredExtensionImport/part_wrapped_script: Fail

pkg/front_end/messages.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -5336,10 +5336,6 @@ JsInteropStaticInteropTrustTypesUsageNotAllowed:
53365336
problemMessage: "JS interop class '#name' has an `@trustTypes` annotation, but `@trustTypes` is only supported within the sdk."
53375337
correctionMessage: "Try removing the `@trustTypes` annotation."
53385338

5339-
DefaultListConstructorError:
5340-
problemMessage: "Can't use the default List constructor."
5341-
correctionMessage: "Try using List.filled instead."
5342-
53435339
NonNullableInNullAware:
53445340
problemMessage: "Operand of null-aware operation '#name' has type '#type' which excludes null."
53455341
severity: WARNING

pkg/front_end/testcases/nnbd/list_constructor.dart

-14
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.strong.expect

-37
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.strong.transformed.expect

-37
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.textual_outline.expect

-2
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.textual_outline_modelled.expect

-2
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.weak.expect

-37
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.weak.modular.expect

-37
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.weak.outline.expect

-8
This file was deleted.

pkg/front_end/testcases/nnbd/list_constructor.dart.weak.transformed.expect

-37
This file was deleted.

pkg/kernel/lib/core_types.dart

-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ class CoreTypes {
182182

183183
late final Class listClass = index.getClass('dart:core', 'List');
184184

185-
late final Procedure listDefaultConstructor =
186-
index.getProcedure('dart:core', 'List', '');
187-
188185
late final Procedure listFromConstructor =
189186
index.getProcedure('dart:core', 'List', 'from');
190187

0 commit comments

Comments
 (0)