Version 2.15.0-203.0.dev
Merge commit '9c10d2b7ffc632e600c4591243eb02081358e74d' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index a2e14e7..3c30694 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -2206,7 +2206,7 @@
if (baseParameter.isNamed) {
argumentValue = _namedValues[baseParameter.name];
errorTarget = _namedNodes[baseParameter.name];
- } else if (i < arguments.length) {
+ } else if (i < _argumentValues.length) {
argumentValue = _argumentValues[i];
errorTarget = arguments[i];
}
diff --git a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
index b8f9aef..3af2022 100644
--- a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
@@ -46,12 +46,14 @@
/**
* Parameters:
- * 0: the name of the struct class
+ * 0: the name of the subclass
+ * 1: the name of the superclass
*/
static const FfiCode EMPTY_STRUCT = FfiCode(
'EMPTY_STRUCT',
- "Struct '{0}' is empty. Empty structs are undefined behavior.",
- correctionMessage: "Try adding a field to '{0}' or use a different Struct.",
+ "The class '{0}' can’t be empty because it's a subclass of '{1}'.",
+ correctionMessage:
+ "Try adding a field to '{0}' or use a different superclass.",
);
/**
diff --git a/pkg/analyzer/lib/src/generated/ffi_verifier.dart b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
index 76f07fd..c8fc471 100644
--- a/pkg/analyzer/lib/src/generated/ffi_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
@@ -78,7 +78,7 @@
compound = node;
if (node.declaredElement!.isEmptyStruct) {
_errorReporter.reportErrorForNode(
- FfiCode.EMPTY_STRUCT, node.name, [node.name.name]);
+ FfiCode.EMPTY_STRUCT, node.name, [node.name.name, className]);
}
if (className == _structClassName) {
_validatePackedAnnotation(node.metadata);
@@ -722,10 +722,10 @@
} else if (declaredType.isCompoundSubtype) {
final clazz = (declaredType as InterfaceType).element;
if (clazz.isEmptyStruct) {
- // TODO(brianwilkerson) There are no tests for this branch. Ensure
- // that the diagnostic is correct and add tests.
- _errorReporter
- .reportErrorForNode(FfiCode.EMPTY_STRUCT, node, [clazz.name]);
+ _errorReporter.reportErrorForNode(FfiCode.EMPTY_STRUCT, node, [
+ clazz.name,
+ clazz.supertype!.getDisplayString(withNullability: false)
+ ]);
}
_validatePackingNesting(compound!.declaredElement!, clazz,
errorNode: fieldType);
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index aa8e577..7f21e4e 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -13746,11 +13746,12 @@
correctionMessage: "Try allocating it via allocation, or load from a 'Pointer'."
comment: No parameters.
EMPTY_STRUCT:
- problemMessage: "Struct '{0}' is empty. Empty structs are undefined behavior."
- correctionMessage: "Try adding a field to '{0}' or use a different Struct."
+ problemMessage: "The class '{0}' can’t be empty because it's a subclass of '{1}'."
+ correctionMessage: "Try adding a field to '{0}' or use a different superclass."
comment: |-
Parameters:
- 0: the name of the struct class
+ 0: the name of the subclass
+ 1: the name of the superclass
EXTRA_ANNOTATION_ON_STRUCT_FIELD:
problemMessage: Fields in a struct class must have exactly one annotation indicating the native type.
correctionMessage: Try removing the extra annotation.
diff --git a/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart b/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
index c3ca2c0..e8e1418 100644
--- a/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/not_enough_positional_arguments_test.dart
@@ -29,6 +29,21 @@
]);
}
+ test_const_namedArgument_insteadOfRequiredPositional() async {
+ await assertErrorsInCode(r'''
+class A {
+ const A(int p);
+}
+main() {
+ const A(p: 0);
+}
+''', [
+ error(CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, 41, 13),
+ error(CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS, 48, 6),
+ error(CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER, 49, 1),
+ ]);
+ }
+
test_const_super() async {
await assertErrorsInCode(r'''
class A {
diff --git a/tools/VERSION b/tools/VERSION
index 481a85b..1a61622 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 202
+PRERELEASE 203
PRERELEASE_PATCH 0
\ No newline at end of file