Skip to content

Commit 433c099

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[cfe] Remove Nullability.legacy
TEST=existing Change-Id: Id924e4ef64ddabc1986cb885f558382ff139b481 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436620 Reviewed-by: Mayank Patke <[email protected]> Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent c30dd25 commit 433c099

File tree

56 files changed

+882
-1963
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+882
-1963
lines changed

pkg/compiler/lib/src/ir/visitors.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
6262
return baseType;
6363
case ir.Nullability.nullable:
6464
return _dartTypes.nullableType(baseType);
65-
case ir.Nullability.legacy:
66-
throw UnsupportedError(
67-
'Unexpected legacy nullability on $nullabilitySource',
68-
);
6965
case ir.Nullability.undetermined:
7066
// Type parameters may have undetermined nullability since it is derived
7167
// from the intersection of the declared nullability with the

pkg/dart2bytecode/lib/bytecode_generator.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,9 @@ class BytecodeGenerator extends RecursiveVisitor {
21002100
final targetTypeParameters = forwardingTarget.function!.typeParameters;
21012101
assert(host.typeParameters.length == targetTypeParameters.length);
21022102
for (int i = 0; i < targetTypeParameters.length; ++i) {
2103-
map[targetTypeParameters[i]] =
2104-
new TypeParameterType(host.typeParameters[i], Nullability.legacy);
2103+
map[targetTypeParameters[i]] = new TypeParameterType(
2104+
host.typeParameters[i],
2105+
host.typeParameters[i].computeNullabilityFromBound());
21052106
}
21062107
}
21072108
return Substitution.fromMap(map);
@@ -2287,7 +2288,8 @@ class BytecodeGenerator extends RecursiveVisitor {
22872288
final DartType bound = (forwardingTypeParameterBounds != null)
22882289
? forwardingTypeParameterBounds[typeParam]!
22892290
: typeParam.bound;
2290-
final DartType type = new TypeParameterType(typeParam, Nullability.legacy);
2291+
final DartType type = new TypeParameterType(
2292+
typeParam, typeParam.computeNullabilityFromBound());
22912293
_genPushInstantiatorAndFunctionTypeArguments([type, bound]);
22922294
asm.emitPushConstant(cp.addType(type));
22932295
asm.emitPushConstant(cp.addType(bound));

pkg/dart2bytecode/lib/object_table.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ String objectKindToString(ObjectKind kind) =>
7171

7272
String nullabilityToString(Nullability nullability) {
7373
switch (nullability) {
74-
case Nullability.legacy:
75-
return '*';
7674
case Nullability.nullable:
7775
return '?';
7876
case Nullability.undetermined:

pkg/dev_compiler/lib/src/kernel/future_or_normalizer.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,11 @@ class FutureOrNormalizer extends ReplacementVisitor {
4343
return typeArgument;
4444
case InterfaceType()
4545
when typeArgument.classNode == _coreTypes.objectClass:
46-
// Normalize FutureOr of Object, Object?, Object*.
47-
var nullable =
46+
// Normalize FutureOr of Object, Object?.
47+
var nullability =
4848
futureOr.nullability == Nullability.nullable ||
49-
typeArgument.nullability == Nullability.nullable;
50-
var legacy =
51-
futureOr.nullability == Nullability.legacy ||
52-
typeArgument.nullability == Nullability.legacy;
53-
var nullability = nullable
49+
typeArgument.nullability == Nullability.nullable
5450
? Nullability.nullable
55-
: legacy
56-
? Nullability.legacy
5751
: Nullability.nonNullable;
5852
return typeArgument.withDeclaredNullability(nullability);
5953
case NeverType() when typeArgument.nullability == Nullability.nonNullable:

pkg/dev_compiler/lib/src/kernel/type_recipe_generator.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ class _TypeRecipeVisitor extends DartTypeVisitor<String> {
587587
return Recipe.wrapQuestionString;
588588
case Nullability.nonNullable:
589589
return '';
590-
case Nullability.legacy:
591-
throw UnsupportedError('Legacy nullability.');
592590
}
593591
}
594592

pkg/dev_compiler/lib/src/kernel/type_table.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,9 @@ Set</* TypeParameter | StructuralParameter */ Object> freeTypeParameters(
6161

6262
/// A name for a type made of JS identifier safe characters.
6363
///
64-
/// 'L' and 'N' are appended to a type name to represent a legacy or nullable
65-
/// flavor of a type.
64+
/// 'N' is appended to a type name to represent a nullable flavor of a type.
6665
String _typeString(DartType type, {bool flat = false}) {
67-
var nullability = type.declaredNullability == Nullability.legacy
68-
? 'L'
69-
: type.declaredNullability == Nullability.nullable
70-
? 'N'
71-
: '';
66+
var nullability = type.declaredNullability == Nullability.nullable ? 'N' : '';
7267
switch (type) {
7368
case InterfaceType():
7469
var name = '${type.classNode.name}$nullability';

pkg/front_end/lib/src/api_prototype/expression_compilation_tools.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ class ParsedType {
279279
if (type == ParsedTypeKind.Null) throw "No nullability on the null type";
280280
if (nullability == 0) return Nullability.nullable;
281281
if (nullability == 1) return Nullability.nonNullable;
282-
if (nullability == 2) return Nullability.legacy;
283282
throw "Unknown nullability";
284283
}
285284
}

pkg/front_end/lib/src/builder/class_builder.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
8484
@override
8585
bool isNullClass = false;
8686

87-
InterfaceType? _legacyRawType;
8887
InterfaceType? _nullableRawType;
8988
InterfaceType? _nonNullableRawType;
9089
InterfaceType? _thisType;
@@ -105,12 +104,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
105104
getAsTypeArguments(cls.typeParameters, libraryBuilder.library));
106105
}
107106

108-
// Coverage-ignore(suite): Not run.
109-
InterfaceType get legacyRawType {
110-
return _legacyRawType ??= new InterfaceType(cls, Nullability.legacy,
111-
new List<DartType>.filled(typeParametersCount, const DynamicType()));
112-
}
113-
114107
InterfaceType get nullableRawType {
115108
return _nullableRawType ??= new InterfaceType(cls, Nullability.nullable,
116109
new List<DartType>.filled(typeParametersCount, const DynamicType()));
@@ -125,9 +118,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
125118

126119
InterfaceType rawType(Nullability nullability) {
127120
switch (nullability) {
128-
case Nullability.legacy:
129-
// Coverage-ignore(suite): Not run.
130-
return legacyRawType;
131121
case Nullability.nullable:
132122
return nullableRawType;
133123
case Nullability.nonNullable:
@@ -243,7 +233,7 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
243233
if (arguments != null) {
244234
List<DartType> typeArguments =
245235
buildAliasedTypeArguments(library, arguments, /* hierarchy = */ null);
246-
typeArguments = unaliasTypes(typeArguments, legacyEraseAliases: false)!;
236+
typeArguments = unaliasTypes(typeArguments)!;
247237
return new Supertype(cls, typeArguments);
248238
} else {
249239
return new Supertype(

pkg/front_end/lib/src/builder/function_type_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ abstract class FunctionTypeBuilderImpl extends FunctionTypeBuilder {
153153
DartType _buildInternal(
154154
LibraryBuilder library, TypeUse typeUse, ClassHierarchyBase? hierarchy) {
155155
DartType aliasedType = buildAliased(library, typeUse, hierarchy);
156-
return unalias(aliasedType, legacyEraseAliases: false);
156+
return unalias(aliasedType);
157157
}
158158

159159
@override

pkg/front_end/lib/src/builder/named_type_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ abstract class NamedTypeBuilderImpl extends NamedTypeBuilder {
489489
typeName.fullNameLength);
490490
}
491491
}
492-
return unaliasing.unalias(aliasedType, legacyEraseAliases: false);
492+
return unaliasing.unalias(aliasedType);
493493
}
494494

495495
@override

0 commit comments

Comments
 (0)