Version 2.16.0-159.0.dev
Merge commit 'edbf6300a13095e164a876ee33251ec91fea072f' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
index 249b33d..b33704b 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
@@ -5871,17 +5871,17 @@
}
extension on FlowModel<Var, Type> {
+ ExpressionInfo<Var, Type> _tryMarkNonNullable(Harness h, Var variable) =>
+ tryMarkNonNullable(h, _varRefWithType(variable));
+
+ ExpressionInfo<Var, Type> _tryPromoteForTypeCheck(
+ Harness h, Var variable, String type) =>
+ tryPromoteForTypeCheck(h, _varRefWithType(variable), Type(type));
+
Reference<Var, Type> _varRef(Var variable) =>
new VariableReference<Var, Type>(variable);
ReferenceWithType<Var, Type> _varRefWithType(Var variable) =>
new ReferenceWithType<Var, Type>(_varRef(variable),
variableInfo[variable]?.promotedTypes?.last ?? variable.type);
-
- ExpressionInfo<Var, Type> _tryPromoteForTypeCheck(
- Harness h, Var variable, String type) =>
- tryPromoteForTypeCheck(h, _varRefWithType(variable), Type(type));
-
- ExpressionInfo<Var, Type> _tryMarkNonNullable(Harness h, Var variable) =>
- tryMarkNonNullable(h, _varRefWithType(variable));
}
diff --git a/pkg/analysis_server/test/services/completion/dart/super_formal_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/super_formal_contributor_test.dart
index ff135e7..88d16b9 100644
--- a/pkg/analysis_server/test/services/completion/dart/super_formal_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/super_formal_contributor_test.dart
@@ -450,7 +450,7 @@
addTestSource('''
class A {
A(int first, double second);
- A.named(int third)
+ A.named(int third);
}
class B extends A {
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 441903a..3555ef1 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -293,9 +293,6 @@
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR,
CompileTimeErrorCode.MIXIN_DEFERRED_CLASS,
- CompileTimeErrorCode.MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
- CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
- CompileTimeErrorCode.MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,
CompileTimeErrorCode.MIXIN_INSTANTIATE,
CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
index 6033cde..0bbf444 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -8912,29 +8912,6 @@
uniqueName: 'MIXIN_DEFERRED_CLASS',
);
- static const CompileTimeErrorCode
- MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES = CompileTimeErrorCode(
- 'MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES',
- "Type parameters couldn't be inferred for the mixin '{0}' because the base "
- "class implements the mixin's supertype constraint '{1}' in multiple "
- "conflicting ways",
- );
-
- static const CompileTimeErrorCode MIXIN_INFERENCE_NO_MATCHING_CLASS =
- CompileTimeErrorCode(
- 'MIXIN_INFERENCE_NO_MATCHING_CLASS',
- "Type parameters couldn't be inferred for the mixin '{0}' because the base "
- "class doesn't implement the mixin's supertype constraint '{1}'",
- );
-
- static const CompileTimeErrorCode MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION =
- CompileTimeErrorCode(
- 'MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION',
- "Type parameters couldn't be inferred for the mixin '{0}' because no type "
- "parameter substitution could be found matching the mixin's supertype "
- "constraints",
- );
-
/**
* Parameters:
* 0: the name of the mixin that is invalid
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 2582044..56a90a4 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -1329,7 +1329,6 @@
CompileTimeErrorCode.IMPLEMENTS_REPEATED);
_checkImplementsSuperClass(implementsClause);
_checkMixinsSuperClass(withClause);
- _checkMixinInference(node, withClause);
_checkForMixinWithConflictingPrivateMember(withClause, superclass);
_checkForConflictingGenerics(node);
if (node is ClassDeclaration) {
@@ -4758,56 +4757,6 @@
}
}
- void _checkMixinInference(
- NamedCompilationUnitMember node, WithClause? withClause) {
- if (withClause == null) {
- return;
- }
- var classElement = node.declaredElement as ClassElement;
- var supertype = classElement.supertype;
-
- var interfacesMerger = InterfacesMerger(typeSystem);
- interfacesMerger.addWithSupertypes(supertype);
-
- for (var namedType in withClause.mixinTypes2) {
- var mixinType = namedType.type;
- if (mixinType is InterfaceType) {
- var mixinElement = mixinType.element;
- if (namedType.typeArguments == null) {
- var mixinSupertypeConstraints = typeSystem
- .gatherMixinSupertypeConstraintsForInference(mixinElement);
- if (mixinSupertypeConstraints.isNotEmpty) {
- var matchingInterfaceTypes = _findInterfaceTypesForConstraints(
- namedType,
- mixinSupertypeConstraints,
- interfacesMerger.typeList,
- );
- if (matchingInterfaceTypes != null) {
- // Try to pattern match matchingInterfaceType against
- // mixinSupertypeConstraint to find the correct set of type
- // parameters to apply to the mixin.
- var inferredTypeArguments = typeSystem.matchSupertypeConstraints(
- mixinElement,
- mixinSupertypeConstraints,
- matchingInterfaceTypes,
- genericMetadataIsEnabled: _currentLibrary.featureSet
- .isEnabled(Feature.generic_metadata),
- );
- if (inferredTypeArguments == null) {
- errorReporter.reportErrorForToken(
- CompileTimeErrorCode
- .MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
- namedType.name.beginToken,
- [namedType]);
- }
- }
- }
- }
- interfacesMerger.addWithSupertypes(mixinType);
- }
- }
- }
-
/// Checks the class for problems with the superclass, mixins, or implemented
/// interfaces.
void _checkMixinInheritance(MixinDeclaration node, OnClause? onClause,
@@ -4965,51 +4914,6 @@
}
}
- InterfaceType? _findInterfaceTypeForMixin(NamedType mixin,
- InterfaceType supertypeConstraint, List<InterfaceType> interfaceTypes) {
- var element = supertypeConstraint.element;
- InterfaceType? foundInterfaceType;
- for (var interfaceType in interfaceTypes) {
- if (interfaceType.element != element) continue;
- if (foundInterfaceType == null) {
- foundInterfaceType = interfaceType;
- } else {
- if (interfaceType != foundInterfaceType) {
- errorReporter.reportErrorForToken(
- CompileTimeErrorCode
- .MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
- mixin.name.beginToken,
- [mixin, supertypeConstraint]);
- }
- }
- }
- if (foundInterfaceType == null) {
- errorReporter.reportErrorForToken(
- CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
- mixin.name.beginToken,
- [mixin, supertypeConstraint]);
- }
- return foundInterfaceType;
- }
-
- List<InterfaceType>? _findInterfaceTypesForConstraints(
- NamedType mixin,
- List<InterfaceType> supertypeConstraints,
- List<InterfaceType> interfaceTypes) {
- var result = <InterfaceType>[];
- for (var constraint in supertypeConstraints) {
- var interfaceType =
- _findInterfaceTypeForMixin(mixin, constraint, interfaceTypes);
- if (interfaceType == null) {
- // No matching interface type found, so inference fails. The error has
- // already been reported.
- return null;
- }
- result.add(interfaceType);
- }
- return result;
- }
-
/// Given an [expression] in a switch case whose value is expected to be an
/// enum constant, return the name of the constant.
String? _getConstantName(Expression expression) {
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index 3b2abaf..22d6045 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -7705,12 +7705,6 @@
class B extends A {}
```
- MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES:
- problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class implements the mixin's supertype constraint '{1}' in multiple conflicting ways"
- MIXIN_INFERENCE_NO_MATCHING_CLASS:
- problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'"
- MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION:
- problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because no type parameter substitution could be found matching the mixin's supertype constraints"
MIXIN_INHERITS_FROM_NOT_OBJECT:
problemMessage: "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'."
hasPublishedDocs: true
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
index 01a7d14..ae2f294 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart
@@ -163,4 +163,18 @@
}
''');
}
+
+ test_parameter_superFormal() async {
+ await assertErrorsInCode('''
+class A {
+ A(int a);
+}
+class B extends A {
+ var x;
+ B(super.a) : x = (() { a = 0; });
+}
+''', [
+ error(CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_LOCAL, 78, 1),
+ ]);
+ }
}
diff --git a/pkg/analyzer/test/src/diagnostics/super_formal_parameter_type_is_not_subtype_of_associated_test.dart b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_type_is_not_subtype_of_associated_test.dart
index b7db53b..b32c05c 100644
--- a/pkg/analyzer/test/src/diagnostics/super_formal_parameter_type_is_not_subtype_of_associated_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/super_formal_parameter_type_is_not_subtype_of_associated_test.dart
@@ -130,6 +130,25 @@
]);
}
+ /// No implicit coercions, like downcast from `dynamic`.
+ test_requiredPositional_explicit_notSubtype_dynamic() async {
+ await assertErrorsInCode(r'''
+class A {
+ A(int a);
+}
+
+class B extends A {
+ B(dynamic super.a);
+}
+''', [
+ error(
+ CompileTimeErrorCode
+ .SUPER_FORMAL_PARAMETER_TYPE_IS_NOT_SUBTYPE_OF_ASSOCIATED,
+ 63,
+ 1),
+ ]);
+ }
+
test_requiredPositional_explicit_same() async {
await assertNoErrorsInCode(r'''
class A {
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 4fb0b3a..16b9b82 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -501,6 +501,17 @@
_assertNonSyntheticElementSelf(e);
}
+ void _writeFieldFormalParameterField(ParameterElement e) {
+ if (e is FieldFormalParameterElement) {
+ var field = e.field;
+ if (field != null) {
+ _writeElementReference('field', field);
+ } else {
+ _writelnWithIndent('field: <null>');
+ }
+ }
+ }
+
void _writeFunctionElement(FunctionElement e) {
_writeIndentedLine(() {
_writeIf(e.isExternal, 'external ');
@@ -671,6 +682,7 @@
_writeParameterElements(e.parameters);
_writeConstantInitializer(e);
_writeNonSyntheticElement(e);
+ _writeFieldFormalParameterField(e);
_writeSuperConstructorParameter(e);
});
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 7a39830..984f6c7 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -246,6 +246,7 @@
parameters
requiredPositional final this.x @36
type: dynamic
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -272,6 +273,7 @@
parameters
requiredPositional final this.x @32
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -298,6 +300,7 @@
parameters
requiredPositional final this.x @28
type: dynamic
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -332,6 +335,7 @@
parameters
requiredPositional b @37
type: double
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -366,6 +370,7 @@
parameters
requiredPositional b @41
type: double
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -403,6 +408,7 @@
parameters
requiredPositional t @53
type: T
+ field: self::@class::C::@field::f
accessors
synthetic get f @-1
returnType: dynamic Function()
@@ -433,6 +439,7 @@
parameters
requiredPositional final this.x @17
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: int
@@ -465,6 +472,7 @@
parameters
requiredPositional final this.x @17
type: dynamic
+ field: <null>
''');
}
@@ -484,6 +492,7 @@
parameters
requiredPositional final this.x @32
type: dynamic
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: num
@@ -510,6 +519,7 @@
parameters
requiredPositional final this.x @28
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: num
@@ -536,6 +546,7 @@
parameters
requiredPositional final this.x @24
type: num
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: num
@@ -562,6 +573,7 @@
parameters
requiredPositional final this.x @32
type: dynamic
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -588,6 +600,7 @@
parameters
requiredPositional final this.x @28
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -614,6 +627,7 @@
parameters
requiredPositional final this.x @24
type: dynamic
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -640,6 +654,7 @@
parameters
optionalNamed final this.x @25
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: int
@@ -670,6 +685,7 @@
IntegerLiteral
literal: 42 @28
staticType: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: int
@@ -696,6 +712,7 @@
parameters
optionalPositional final this.x @25
type: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: int
@@ -726,6 +743,7 @@
IntegerLiteral
literal: 42 @29
staticType: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: int
@@ -3640,6 +3658,7 @@
parameters
requiredPositional final this.foo @36
type: int
+ field: self::@class::A::@field::foo
accessors
synthetic get foo @-1
returnType: int
@@ -3668,6 +3687,7 @@
parameters
requiredPositional final this.v @34
type: int
+ field: self::@class::C::@field::v
superConstructor: self::@class::D::@constructor::•
accessors
synthetic get v @-1
@@ -9875,12 +9895,14 @@
parameters
requiredPositional final this.t @41
type: T
+ field: self::@class::C::@field::t
const named @55
periodOffset: 54
nameEnd: 60
parameters
requiredPositional final this.t @66
type: T
+ field: self::@class::C::@field::t
accessors
synthetic get t @-1
returnType: T
@@ -12525,6 +12547,7 @@
staticElement: self::@function::foo
staticType: int Function()
token: foo @40
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -12566,6 +12589,7 @@
staticElement: dart:core::@class::num::@method::+
staticInvokeType: num Function(num)
staticType: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -12604,6 +12628,7 @@
staticElement: dart:core::@class::num::@method::+
staticInvokeType: num Function(num)
staticType: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -15915,6 +15940,7 @@
staticType: void Function(dynamic)
typeArgumentTypes
dynamic
+ field: self::@class::X::@field::f
accessors
synthetic get f @-1
returnType: void Function(dynamic)
@@ -17956,6 +17982,7 @@
parameters
requiredPositional final this.a @16
type: int
+ field: <null>
returnType: void
''');
}
@@ -17976,6 +18003,7 @@
IntegerLiteral
literal: 42 @20
staticType: int
+ field: <null>
returnType: void
''');
}
@@ -17995,6 +18023,7 @@
parameters
requiredPositional b @22
type: int
+ field: <null>
returnType: void
''');
}
@@ -19669,6 +19698,7 @@
parameters
requiredPositional final this.x @49
type: Object
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: Object
@@ -22558,6 +22588,7 @@
parameters
requiredPositional final this.foo @41
type: dynamic
+ field: <null>
returnType: void
''');
}
@@ -22583,6 +22614,7 @@
parameters
requiredPositional final this.x @23
type: dynamic
+ field: <null>
returnType: void
''');
}
@@ -24166,6 +24198,7 @@
parameters
requiredPositional final this.value @48
type: dynamic
+ field: self::@class::A::@field::value
accessors
synthetic get value @-1
returnType: dynamic
@@ -24500,6 +24533,7 @@
staticElement: self::@getter::a
staticType: null
token: a @40
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -24549,6 +24583,7 @@
NullLiteral
literal: null @48
staticType: Null
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -28926,6 +28961,7 @@
IntegerLiteral
literal: 1 @44
staticType: int
+ field: self::@class::C::@field::x
named @53
periodOffset: 52
nameEnd: 58
@@ -28936,6 +28972,7 @@
IntegerLiteral
literal: 1 @68
staticType: int
+ field: self::@class::C::@field::x
accessors
synthetic get x @-1
returnType: dynamic
@@ -29615,6 +29652,7 @@
parameters
requiredPositional final this.value @34
type: T
+ field: self::@class::A::@field::value
accessors
synthetic get value @-1
returnType: T
@@ -29672,6 +29710,7 @@
parameters
requiredPositional final this.value @34
type: T
+ field: self::@class::A::@field::value
accessors
synthetic get value @-1
returnType: T
@@ -29753,6 +29792,7 @@
parameters
requiredPositional final this.f @35
type: int
+ field: self::@class::A::@field::f
accessors
synthetic get f @-1
returnType: int
@@ -29937,6 +29977,7 @@
parameters
requiredPositional final this.f @85
type: T
+ field: self::@class::C::@field::f
accessors
synthetic get f @-1
returnType: T
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index 7a9a91c..f152265 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -3478,6 +3478,7 @@
constantInitializer
SimpleStringLiteral
literal: 'hello' @37
+ field: self::@class::A::@field::f
accessors
synthetic get f @-1
returnType: int
diff --git a/tools/VERSION b/tools/VERSION
index 856c72a..6c960b2 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 158
+PRERELEASE 159
PRERELEASE_PATCH 0
\ No newline at end of file