Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 099f7f5

Browse files
author
Dart CI
committed
Version 2.16.0-159.0.dev
Merge commit 'edbf6300a13095e164a876ee33251ec91fea072f' into 'dev'
2 parents 8a8fb09 + edbf630 commit 099f7f5

File tree

12 files changed

+96
-137
lines changed

12 files changed

+96
-137
lines changed

pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5871,17 +5871,17 @@ class _MockNonPromotionReason extends NonPromotionReason {
58715871
}
58725872

58735873
extension on FlowModel<Var, Type> {
5874+
ExpressionInfo<Var, Type> _tryMarkNonNullable(Harness h, Var variable) =>
5875+
tryMarkNonNullable(h, _varRefWithType(variable));
5876+
5877+
ExpressionInfo<Var, Type> _tryPromoteForTypeCheck(
5878+
Harness h, Var variable, String type) =>
5879+
tryPromoteForTypeCheck(h, _varRefWithType(variable), Type(type));
5880+
58745881
Reference<Var, Type> _varRef(Var variable) =>
58755882
new VariableReference<Var, Type>(variable);
58765883

58775884
ReferenceWithType<Var, Type> _varRefWithType(Var variable) =>
58785885
new ReferenceWithType<Var, Type>(_varRef(variable),
58795886
variableInfo[variable]?.promotedTypes?.last ?? variable.type);
5880-
5881-
ExpressionInfo<Var, Type> _tryPromoteForTypeCheck(
5882-
Harness h, Var variable, String type) =>
5883-
tryPromoteForTypeCheck(h, _varRefWithType(variable), Type(type));
5884-
5885-
ExpressionInfo<Var, Type> _tryMarkNonNullable(Harness h, Var variable) =>
5886-
tryMarkNonNullable(h, _varRefWithType(variable));
58875887
}

pkg/analysis_server/test/services/completion/dart/super_formal_contributor_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class B extends A {
450450
addTestSource('''
451451
class A {
452452
A(int first, double second);
453-
A.named(int third)
453+
A.named(int third);
454454
}
455455
456456
class B extends A {

pkg/analyzer/lib/error/error.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ const List<ErrorCode> errorCodeValues = [
293293
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
294294
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR,
295295
CompileTimeErrorCode.MIXIN_DEFERRED_CLASS,
296-
CompileTimeErrorCode.MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
297-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
298-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
299296
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,
300297
CompileTimeErrorCode.MIXIN_INSTANTIATE,
301298
CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8912,29 +8912,6 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
89128912
uniqueName: 'MIXIN_DEFERRED_CLASS',
89138913
);
89148914

8915-
static const CompileTimeErrorCode
8916-
MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES = CompileTimeErrorCode(
8917-
'MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES',
8918-
"Type parameters couldn't be inferred for the mixin '{0}' because the base "
8919-
"class implements the mixin's supertype constraint '{1}' in multiple "
8920-
"conflicting ways",
8921-
);
8922-
8923-
static const CompileTimeErrorCode MIXIN_INFERENCE_NO_MATCHING_CLASS =
8924-
CompileTimeErrorCode(
8925-
'MIXIN_INFERENCE_NO_MATCHING_CLASS',
8926-
"Type parameters couldn't be inferred for the mixin '{0}' because the base "
8927-
"class doesn't implement the mixin's supertype constraint '{1}'",
8928-
);
8929-
8930-
static const CompileTimeErrorCode MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION =
8931-
CompileTimeErrorCode(
8932-
'MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION',
8933-
"Type parameters couldn't be inferred for the mixin '{0}' because no type "
8934-
"parameter substitution could be found matching the mixin's supertype "
8935-
"constraints",
8936-
);
8937-
89388915
/**
89398916
* Parameters:
89408917
* 0: the name of the mixin that is invalid

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
13291329
CompileTimeErrorCode.IMPLEMENTS_REPEATED);
13301330
_checkImplementsSuperClass(implementsClause);
13311331
_checkMixinsSuperClass(withClause);
1332-
_checkMixinInference(node, withClause);
13331332
_checkForMixinWithConflictingPrivateMember(withClause, superclass);
13341333
_checkForConflictingGenerics(node);
13351334
if (node is ClassDeclaration) {
@@ -4758,56 +4757,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
47584757
}
47594758
}
47604759

4761-
void _checkMixinInference(
4762-
NamedCompilationUnitMember node, WithClause? withClause) {
4763-
if (withClause == null) {
4764-
return;
4765-
}
4766-
var classElement = node.declaredElement as ClassElement;
4767-
var supertype = classElement.supertype;
4768-
4769-
var interfacesMerger = InterfacesMerger(typeSystem);
4770-
interfacesMerger.addWithSupertypes(supertype);
4771-
4772-
for (var namedType in withClause.mixinTypes2) {
4773-
var mixinType = namedType.type;
4774-
if (mixinType is InterfaceType) {
4775-
var mixinElement = mixinType.element;
4776-
if (namedType.typeArguments == null) {
4777-
var mixinSupertypeConstraints = typeSystem
4778-
.gatherMixinSupertypeConstraintsForInference(mixinElement);
4779-
if (mixinSupertypeConstraints.isNotEmpty) {
4780-
var matchingInterfaceTypes = _findInterfaceTypesForConstraints(
4781-
namedType,
4782-
mixinSupertypeConstraints,
4783-
interfacesMerger.typeList,
4784-
);
4785-
if (matchingInterfaceTypes != null) {
4786-
// Try to pattern match matchingInterfaceType against
4787-
// mixinSupertypeConstraint to find the correct set of type
4788-
// parameters to apply to the mixin.
4789-
var inferredTypeArguments = typeSystem.matchSupertypeConstraints(
4790-
mixinElement,
4791-
mixinSupertypeConstraints,
4792-
matchingInterfaceTypes,
4793-
genericMetadataIsEnabled: _currentLibrary.featureSet
4794-
.isEnabled(Feature.generic_metadata),
4795-
);
4796-
if (inferredTypeArguments == null) {
4797-
errorReporter.reportErrorForToken(
4798-
CompileTimeErrorCode
4799-
.MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION,
4800-
namedType.name.beginToken,
4801-
[namedType]);
4802-
}
4803-
}
4804-
}
4805-
}
4806-
interfacesMerger.addWithSupertypes(mixinType);
4807-
}
4808-
}
4809-
}
4810-
48114760
/// Checks the class for problems with the superclass, mixins, or implemented
48124761
/// interfaces.
48134762
void _checkMixinInheritance(MixinDeclaration node, OnClause? onClause,
@@ -4965,51 +4914,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
49654914
}
49664915
}
49674916

4968-
InterfaceType? _findInterfaceTypeForMixin(NamedType mixin,
4969-
InterfaceType supertypeConstraint, List<InterfaceType> interfaceTypes) {
4970-
var element = supertypeConstraint.element;
4971-
InterfaceType? foundInterfaceType;
4972-
for (var interfaceType in interfaceTypes) {
4973-
if (interfaceType.element != element) continue;
4974-
if (foundInterfaceType == null) {
4975-
foundInterfaceType = interfaceType;
4976-
} else {
4977-
if (interfaceType != foundInterfaceType) {
4978-
errorReporter.reportErrorForToken(
4979-
CompileTimeErrorCode
4980-
.MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES,
4981-
mixin.name.beginToken,
4982-
[mixin, supertypeConstraint]);
4983-
}
4984-
}
4985-
}
4986-
if (foundInterfaceType == null) {
4987-
errorReporter.reportErrorForToken(
4988-
CompileTimeErrorCode.MIXIN_INFERENCE_NO_MATCHING_CLASS,
4989-
mixin.name.beginToken,
4990-
[mixin, supertypeConstraint]);
4991-
}
4992-
return foundInterfaceType;
4993-
}
4994-
4995-
List<InterfaceType>? _findInterfaceTypesForConstraints(
4996-
NamedType mixin,
4997-
List<InterfaceType> supertypeConstraints,
4998-
List<InterfaceType> interfaceTypes) {
4999-
var result = <InterfaceType>[];
5000-
for (var constraint in supertypeConstraints) {
5001-
var interfaceType =
5002-
_findInterfaceTypeForMixin(mixin, constraint, interfaceTypes);
5003-
if (interfaceType == null) {
5004-
// No matching interface type found, so inference fails. The error has
5005-
// already been reported.
5006-
return null;
5007-
}
5008-
result.add(interfaceType);
5009-
}
5010-
return result;
5011-
}
5012-
50134917
/// Given an [expression] in a switch case whose value is expected to be an
50144918
/// enum constant, return the name of the constant.
50154919
String? _getConstantName(Expression expression) {

pkg/analyzer/messages.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7705,12 +7705,6 @@ CompileTimeErrorCode:
77057705

77067706
class B extends A {}
77077707
```
7708-
MIXIN_INFERENCE_INCONSISTENT_MATCHING_CLASSES:
7709-
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"
7710-
MIXIN_INFERENCE_NO_MATCHING_CLASS:
7711-
problemMessage: "Type parameters couldn't be inferred for the mixin '{0}' because the base class doesn't implement the mixin's supertype constraint '{1}'"
7712-
MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION:
7713-
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"
77147708
MIXIN_INHERITS_FROM_NOT_OBJECT:
77157709
problemMessage: "The class '{0}' can't be used as a mixin because it extends a class other than 'Object'."
77167710
hasPublishedDocs: true

pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,18 @@ void f() {
163163
}
164164
''');
165165
}
166+
167+
test_parameter_superFormal() async {
168+
await assertErrorsInCode('''
169+
class A {
170+
A(int a);
171+
}
172+
class B extends A {
173+
var x;
174+
B(super.a) : x = (() { a = 0; });
175+
}
176+
''', [
177+
error(CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_LOCAL, 78, 1),
178+
]);
179+
}
166180
}

pkg/analyzer/test/src/diagnostics/super_formal_parameter_type_is_not_subtype_of_associated_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ class B extends A {
130130
]);
131131
}
132132

133+
/// No implicit coercions, like downcast from `dynamic`.
134+
test_requiredPositional_explicit_notSubtype_dynamic() async {
135+
await assertErrorsInCode(r'''
136+
class A {
137+
A(int a);
138+
}
139+
140+
class B extends A {
141+
B(dynamic super.a);
142+
}
143+
''', [
144+
error(
145+
CompileTimeErrorCode
146+
.SUPER_FORMAL_PARAMETER_TYPE_IS_NOT_SUBTYPE_OF_ASSOCIATED,
147+
63,
148+
1),
149+
]);
150+
}
151+
133152
test_requiredPositional_explicit_same() async {
134153
await assertNoErrorsInCode(r'''
135154
class A {

pkg/analyzer/test/src/summary/element_text.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,17 @@ class _ElementWriter {
501501
_assertNonSyntheticElementSelf(e);
502502
}
503503

504+
void _writeFieldFormalParameterField(ParameterElement e) {
505+
if (e is FieldFormalParameterElement) {
506+
var field = e.field;
507+
if (field != null) {
508+
_writeElementReference('field', field);
509+
} else {
510+
_writelnWithIndent('field: <null>');
511+
}
512+
}
513+
}
514+
504515
void _writeFunctionElement(FunctionElement e) {
505516
_writeIndentedLine(() {
506517
_writeIf(e.isExternal, 'external ');
@@ -671,6 +682,7 @@ class _ElementWriter {
671682
_writeParameterElements(e.parameters);
672683
_writeConstantInitializer(e);
673684
_writeNonSyntheticElement(e);
685+
_writeFieldFormalParameterField(e);
674686
_writeSuperConstructorParameter(e);
675687
});
676688
}

0 commit comments

Comments
 (0)