Skip to content

Commit 9b3b9c2

Browse files
author
Dart CI
committed
Version 2.10.0-134.0.dev
Merge commit 'c9576a1dac4b155be545ac396e2a532a1208d7e9' into 'dev'
2 parents 612540f + c9576a1 commit 9b3b9c2

15 files changed

+406
-145
lines changed

pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,10 @@ class TypeConstraintGatherer {
139139

140140
// If `Q` is a legacy type `Q0*` then the match holds under constraint
141141
// set `C`:
142+
// Only if `P` is a subtype match for `Q?` under constraint set `C`.
142143
if (Q_nullability == NullabilitySuffix.star) {
143-
if (identical(P, DynamicTypeImpl.instance) ||
144-
identical(P, VoidTypeImpl.instance)) {
145-
// If `P` is `dynamic` or `void` and `P` is a subtype match
146-
// for `Q0` under constraint set `C`.
147-
var Q0 = (Q as TypeImpl).withNullability(NullabilitySuffix.none);
148-
return trySubtypeMatch(P, Q0, leftSchema);
149-
} else {
150-
// Or if `P` is not `dynamic` or `void` and `P` is a subtype match
151-
// for `Q0?` under constraint set `C`.
152-
var Qq = (Q as TypeImpl).withNullability(NullabilitySuffix.question);
153-
return trySubtypeMatch(P, Qq, leftSchema);
154-
}
144+
var Qq = (Q as TypeImpl).withNullability(NullabilitySuffix.question);
145+
return trySubtypeMatch(P, Qq, leftSchema);
155146
}
156147

157148
// If `Q` is `FutureOr<Q0>` the match holds under constraint set `C`:
@@ -210,16 +201,6 @@ class TypeConstraintGatherer {
210201
_constraints.length = rewind;
211202
}
212203

213-
// Or if `P` is `dynamic` or `void` and `Object` is a subtype match
214-
// for `Q0` under constraint set `C`.
215-
if (identical(P, DynamicTypeImpl.instance) ||
216-
identical(P, VoidTypeImpl.instance)) {
217-
if (trySubtypeMatch(_typeSystem.objectNone, Q0, leftSchema)) {
218-
return true;
219-
}
220-
_constraints.length = rewind;
221-
}
222-
223204
// Or if `P` is a subtype match for `Q0` under non-empty
224205
// constraint set `C`.
225206
var P_matches_Q0 = trySubtypeMatch(P, Q0, leftSchema);

pkg/analyzer/test/src/dart/element/type_constraint_gatherer_test.dart

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -841,29 +841,6 @@ class TypeConstraintGathererTest extends AbstractTypeSystemNullSafetyTest {
841841
_checkMatch([T], numStar, T_star, true, ['num <: T <: _']);
842842
}
843843

844-
/// If `Q` is a legacy type `Q0*` then the match holds under constraint
845-
/// set `C`:
846-
/// If `P` is `dynamic` or `void` and `P` is a subtype match for `Q0`
847-
/// under constraint set `C`.
848-
test_left_top_right_legacy() {
849-
var U = typeParameter('U', bound: objectNone);
850-
var U_star = typeParameterTypeStar(U);
851-
852-
_checkMatch([U], dynamicNone, U_star, false, ['dynamic <: U <: _']);
853-
_checkMatch([U], voidNone, U_star, false, ['void <: U <: _']);
854-
}
855-
856-
/// If `Q` is `Q0?` the match holds under constraint set `C`:
857-
/// Or if `P` is `dynamic` or `void` and `Object` is a subtype match
858-
/// for `Q0` under constraint set `C`.
859-
test_left_top_right_nullable() {
860-
var U = typeParameter('U', bound: objectNone);
861-
var U_question = typeParameterTypeQuestion(U);
862-
863-
_checkMatch([U], dynamicNone, U_question, false, ['Object <: U <: _']);
864-
_checkMatch([U], voidNone, U_question, false, ['Object <: U <: _']);
865-
}
866-
867844
/// If `P` is a type variable `X` in `L`, then the match holds:
868845
/// Under constraint `_ <: X <: Q`.
869846
test_left_typeParameter() {

pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,34 +2600,4 @@ main() {
26002600

26012601
assertType(findNode.cascade('A()'), 'A');
26022602
}
2603-
2604-
test_typeArgumentTypes_generic_inferred_leftTop_dynamic() async {
2605-
await assertNoErrorsInCode('''
2606-
void foo<T extends Object>(T? value) {}
2607-
2608-
void f(dynamic o) {
2609-
foo(o);
2610-
}
2611-
''');
2612-
2613-
assertTypeArgumentTypes(
2614-
findNode.methodInvocation('foo(o)'),
2615-
['Object'],
2616-
);
2617-
}
2618-
2619-
test_typeArgumentTypes_generic_inferred_leftTop_void() async {
2620-
await assertNoErrorsInCode('''
2621-
void foo<T extends Object>(List<T?> value) {}
2622-
2623-
void f(List<void> o) {
2624-
foo(o);
2625-
}
2626-
''');
2627-
2628-
assertTypeArgumentTypes(
2629-
findNode.methodInvocation('foo(o)'),
2630-
['Object'],
2631-
);
2632-
}
26332603
}

pkg/front_end/lib/src/fasta/kernel/class_hierarchy_builder.dart

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,76 +2965,84 @@ class InterfaceConflict extends DelayedMember {
29652965
return combinedMemberSignatureResult =
29662966
declarations.first.getMember(hierarchy);
29672967
}
2968-
bool isNonNullableByDefault = classBuilder.library.isNonNullableByDefault;
2969-
DartType thisType = hierarchy.coreTypes
2970-
.thisInterfaceType(classBuilder.cls, classBuilder.library.nonNullable);
2971-
List<DartType> candidateTypes = new List<DartType>(declarations.length);
29722968
ClassMember bestSoFar;
29732969
int bestSoFarIndex;
2974-
DartType bestTypeSoFar;
29752970
Map<DartType, int> mutualSubtypes;
2976-
for (int candidateIndex = declarations.length - 1;
2977-
candidateIndex >= 0;
2978-
candidateIndex--) {
2979-
ClassMember candidate = declarations[candidateIndex];
2980-
Member target = candidate.getMember(hierarchy);
2981-
assert(target != null,
2982-
"No member computed for ${candidate} (${candidate.runtimeType})");
2983-
DartType candidateType = computeMemberType(hierarchy, thisType, target);
2984-
if (!isNonNullableByDefault) {
2985-
candidateType = legacyErasure(hierarchy.coreTypes, candidateType);
2986-
}
2987-
candidateTypes[candidateIndex] = candidateType;
2988-
if (bestSoFar == null) {
2989-
bestSoFar = candidate;
2990-
bestTypeSoFar = candidateType;
2991-
bestSoFarIndex = candidateIndex;
2992-
} else {
2993-
if (isMoreSpecific(hierarchy, candidateType, bestTypeSoFar)) {
2994-
debug?.log("Combined Member Signature: ${candidate.fullName} "
2995-
"${candidateType} <: ${bestSoFar.fullName} ${bestTypeSoFar}");
2996-
if (isNonNullableByDefault &&
2997-
isMoreSpecific(hierarchy, bestTypeSoFar, candidateType)) {
2998-
if (mutualSubtypes == null) {
2999-
mutualSubtypes = {
3000-
bestTypeSoFar: bestSoFarIndex,
3001-
candidateType: candidateIndex
3002-
};
2971+
if (declarations.length == 1) {
2972+
bestSoFar = declarations[0];
2973+
bestSoFarIndex = 0;
2974+
} else {
2975+
DartType thisType = hierarchy.coreTypes.thisInterfaceType(
2976+
classBuilder.cls, classBuilder.library.nonNullable);
2977+
bool isNonNullableByDefault = classBuilder.library.isNonNullableByDefault;
2978+
2979+
DartType bestTypeSoFar;
2980+
List<DartType> candidateTypes = new List<DartType>(declarations.length);
2981+
for (int candidateIndex = declarations.length - 1;
2982+
candidateIndex >= 0;
2983+
candidateIndex--) {
2984+
ClassMember candidate = declarations[candidateIndex];
2985+
Member target = candidate.getMember(hierarchy);
2986+
assert(target != null,
2987+
"No member computed for ${candidate} (${candidate.runtimeType})");
2988+
DartType candidateType = computeMemberType(hierarchy, thisType, target);
2989+
if (!isNonNullableByDefault) {
2990+
candidateType = legacyErasure(hierarchy.coreTypes, candidateType);
2991+
}
2992+
candidateTypes[candidateIndex] = candidateType;
2993+
if (bestSoFar == null) {
2994+
bestSoFar = candidate;
2995+
bestTypeSoFar = candidateType;
2996+
bestSoFarIndex = candidateIndex;
2997+
} else {
2998+
if (isMoreSpecific(hierarchy, candidateType, bestTypeSoFar)) {
2999+
debug?.log("Combined Member Signature: ${candidate.fullName} "
3000+
"${candidateType} <: ${bestSoFar.fullName} ${bestTypeSoFar}");
3001+
if (isNonNullableByDefault &&
3002+
isMoreSpecific(hierarchy, bestTypeSoFar, candidateType)) {
3003+
if (mutualSubtypes == null) {
3004+
mutualSubtypes = {
3005+
bestTypeSoFar: bestSoFarIndex,
3006+
candidateType: candidateIndex
3007+
};
3008+
} else {
3009+
mutualSubtypes[candidateType] = candidateIndex;
3010+
}
30033011
} else {
3004-
mutualSubtypes[candidateType] = candidateIndex;
3012+
mutualSubtypes = null;
30053013
}
3014+
bestSoFarIndex = candidateIndex;
3015+
bestSoFar = candidate;
3016+
bestTypeSoFar = candidateType;
30063017
} else {
3007-
mutualSubtypes = null;
3018+
debug?.log("Combined Member Signature: "
3019+
"${candidate.fullName} !<: ${bestSoFar.fullName}");
30083020
}
3009-
bestSoFarIndex = candidateIndex;
3010-
bestSoFar = candidate;
3011-
bestTypeSoFar = candidateType;
3012-
} else {
3013-
debug?.log("Combined Member Signature: "
3014-
"${candidate.fullName} !<: ${bestSoFar.fullName}");
30153021
}
30163022
}
3017-
}
3018-
if (bestSoFar != null) {
3019-
debug?.log("Combined Member Signature bestSoFar: ${bestSoFar.fullName}");
3020-
for (int candidateIndex = 0;
3021-
candidateIndex < declarations.length;
3022-
candidateIndex++) {
3023-
ClassMember candidate = declarations[candidateIndex];
3024-
DartType candidateType = candidateTypes[candidateIndex];
3025-
if (!isMoreSpecific(hierarchy, bestTypeSoFar, candidateType)) {
3026-
debug?.log("Combined Member Signature: "
3027-
"${bestSoFar.fullName} !<: ${candidate.fullName}");
3028-
3029-
if (!shouldOverrideProblemBeOverlooked(classBuilder)) {
3030-
bestSoFar = null;
3031-
bestTypeSoFar = null;
3032-
mutualSubtypes = null;
3023+
if (bestSoFar != null) {
3024+
debug?.log("Combined Member Signature bestSoFar: "
3025+
"${bestSoFar.fullName}");
3026+
for (int candidateIndex = 0;
3027+
candidateIndex < declarations.length;
3028+
candidateIndex++) {
3029+
ClassMember candidate = declarations[candidateIndex];
3030+
DartType candidateType = candidateTypes[candidateIndex];
3031+
if (!isMoreSpecific(hierarchy, bestTypeSoFar, candidateType)) {
3032+
debug?.log("Combined Member Signature: "
3033+
"${bestSoFar.fullName} !<: ${candidate.fullName}");
3034+
3035+
if (!shouldOverrideProblemBeOverlooked(classBuilder)) {
3036+
bestSoFar = null;
3037+
bestTypeSoFar = null;
3038+
mutualSubtypes = null;
3039+
}
3040+
break;
30333041
}
3034-
break;
30353042
}
30363043
}
30373044
}
3045+
30383046
if (bestSoFar == null) {
30393047
String name = classBuilder.fullNameForErrors;
30403048
int length = classBuilder.isAnonymousMixinApplication ? 1 : name.length;
@@ -3058,16 +3066,16 @@ class InterfaceConflict extends DelayedMember {
30583066
debug?.log("Combined Member Signature of ${fullNameForErrors}: "
30593067
"${bestSoFar.fullName}");
30603068

3061-
ProcedureKind kind = ProcedureKind.Method;
3062-
Member bestMemberSoFar = bestSoFar.getMember(hierarchy);
3063-
if (bestSoFar.isProperty) {
3064-
kind = isSetter ? ProcedureKind.Setter : ProcedureKind.Getter;
3065-
} else if (bestMemberSoFar is Procedure &&
3066-
bestMemberSoFar.kind == ProcedureKind.Operator) {
3067-
kind = ProcedureKind.Operator;
3068-
}
3069-
30703069
if (modifyKernel) {
3070+
ProcedureKind kind = ProcedureKind.Method;
3071+
Member bestMemberSoFar = bestSoFar.getMember(hierarchy);
3072+
if (bestSoFar.isProperty) {
3073+
kind = isSetter ? ProcedureKind.Setter : ProcedureKind.Getter;
3074+
} else if (bestMemberSoFar is Procedure &&
3075+
bestMemberSoFar.kind == ProcedureKind.Operator) {
3076+
kind = ProcedureKind.Operator;
3077+
}
3078+
30713079
debug?.log("Combined Member Signature of ${fullNameForErrors}: new "
30723080
"ForwardingNode($classBuilder, $bestSoFar, $declarations, $kind)");
30733081
Member stub = new ForwardingNode(

0 commit comments

Comments
 (0)