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

Commit cc1cc0b

Browse files
Dmitry Stefantsovcommit-bot@chromium.org
authored andcommitted
Revert "[cfe] Pass variance through in ReplacementVisitor"
This reverts commit a212650. Reason for revert: Regressions detected by the Dart CI bot. Original change's description: > [cfe] Pass variance through in ReplacementVisitor > > Change-Id: I8dc9c1a77c5dfe70ad186bbd6254aaf5353aa0ca > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180900 > Reviewed-by: Johnni Winther <[email protected]> > Commit-Queue: Dmitry Stefantsov <[email protected]> [email protected],[email protected] Change-Id: I678c9f013b1df9c7fe4da043fc1e1b19d3f24168 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181202 Reviewed-by: Dmitry Stefantsov <[email protected]> Commit-Queue: Dmitry Stefantsov <[email protected]>
1 parent d373094 commit cc1cc0b

File tree

8 files changed

+251
-231
lines changed

8 files changed

+251
-231
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,12 @@ class _HasPromotedTypeVariableVisitor extends DartTypeVisitor<bool> {
6565
/// with legacy types.
6666
DartType demoteTypeInLibrary(DartType type, Library library) {
6767
if (library.isNonNullableByDefault) {
68-
return type.accept1(
69-
const _DemotionNullabilityNormalization(
70-
demoteTypeVariables: true, forNonNullableByDefault: true),
71-
Variance.covariant) ??
68+
return type.accept(const _DemotionNullabilityNormalization(
69+
demoteTypeVariables: true, forNonNullableByDefault: true)) ??
7270
type;
7371
} else {
74-
return type.accept1(
75-
const _DemotionNullabilityNormalization(
76-
demoteTypeVariables: true, forNonNullableByDefault: false),
77-
Variance.covariant) ??
72+
return type.accept(const _DemotionNullabilityNormalization(
73+
demoteTypeVariables: true, forNonNullableByDefault: false)) ??
7874
type;
7975
}
8076
}
@@ -89,10 +85,8 @@ DartType normalizeNullabilityInLibrary(DartType type, Library library) {
8985
if (library.isNonNullableByDefault) {
9086
return type;
9187
} else {
92-
return type.accept1(
93-
const _DemotionNullabilityNormalization(
94-
demoteTypeVariables: false, forNonNullableByDefault: false),
95-
Variance.covariant) ??
88+
return type.accept(const _DemotionNullabilityNormalization(
89+
demoteTypeVariables: false, forNonNullableByDefault: false)) ??
9690
type;
9791
}
9892
}
@@ -125,7 +119,7 @@ class _DemotionNullabilityNormalization extends ReplacementVisitor {
125119
}
126120

127121
@override
128-
DartType visitTypeParameterType(TypeParameterType node, int variance) {
122+
DartType visitTypeParameterType(TypeParameterType node) {
129123
Nullability newNullability = visitNullability(node);
130124
if (demoteTypeVariables && node.promotedBound != null) {
131125
return new TypeParameterType(

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ class _TypeSchemaEliminationVisitor extends ReplacementVisitor {
5353
final DartType topType;
5454
final DartType bottomType;
5555

56-
_TypeSchemaEliminationVisitor(this.topType, this.bottomType);
56+
bool isLeastClosure;
57+
58+
_TypeSchemaEliminationVisitor(
59+
this.isLeastClosure, this.topType, this.bottomType);
60+
61+
void changeVariance() {
62+
isLeastClosure = !isLeastClosure;
63+
}
5764

5865
@override
59-
DartType defaultDartType(DartType node, int variance) {
60-
bool isLeastClosure = variance == Variance.covariant;
66+
DartType defaultDartType(DartType node) {
6167
if (node is UnknownType) {
6268
return isLeastClosure ? bottomType : topType;
6369
}
@@ -78,9 +84,9 @@ class _TypeSchemaEliminationVisitor extends ReplacementVisitor {
7884
assert(bottomType == const NeverType(Nullability.nonNullable) ||
7985
bottomType is NullType);
8086
_TypeSchemaEliminationVisitor visitor =
81-
new _TypeSchemaEliminationVisitor(topType, bottomType);
82-
DartType result = schema.accept1(
83-
visitor, isLeastClosure ? Variance.covariant : Variance.contravariant);
87+
new _TypeSchemaEliminationVisitor(isLeastClosure, topType, bottomType);
88+
DartType result = schema.accept(visitor);
89+
assert(visitor.isLeastClosure == isLeastClosure);
8490
return result ?? schema;
8591
}
8692
}

pkg/front_end/test/spell_checking_list_common.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,6 @@ discards
878878
discover
879879
discovered
880880
discovery
881-
discrepancy
882881
disk
883882
dispatch
884883
dispatches
@@ -1605,7 +1604,6 @@ invariantly
16051604
inversion
16061605
invert
16071606
inverted
1608-
inverter
16091607
investigate
16101608
invisible
16111609
invocation

0 commit comments

Comments
 (0)