Skip to content

Commit 1f8ab5f

Browse files
fishythefishCommit Queue
authored andcommitted
[dart2js, ddc] Remove LEGACY_TYPE_REF.
Bug: #60327 Change-Id: I30017acd7087227e646b230078066208fb27e398 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416060 Reviewed-by: Nicholas Shahan <[email protected]> Reviewed-by: Nate Biggs <[email protected]>
1 parent 5543581 commit 1f8ab5f

File tree

8 files changed

+52
-170
lines changed

8 files changed

+52
-170
lines changed

pkg/compiler/lib/src/ssa/builder.dart

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,8 +5561,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
55615561
_handleCreateInvocationMirror(invocation, sourceInformation);
55625562
} else if (name == 'TYPE_REF') {
55635563
_handleForeignTypeRef(invocation, sourceInformation);
5564-
} else if (name == 'LEGACY_TYPE_REF') {
5565-
_handleForeignLegacyTypeRef(invocation, sourceInformation);
55665564
} else if (name == 'createJsSentinel') {
55675565
_handleForeignCreateJsSentinel(invocation, sourceInformation);
55685566
} else if (name == 'isJsSentinel') {
@@ -6653,32 +6651,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
66536651
);
66546652
}
66556653

6656-
void _handleForeignLegacyTypeRef(
6657-
ir.StaticInvocation invocation,
6658-
SourceInformation? sourceInformation,
6659-
) {
6660-
if (_unexpectedForeignArguments(
6661-
invocation,
6662-
minPositional: 0,
6663-
maxPositional: 0,
6664-
typeArgumentCount: 1,
6665-
)) {
6666-
stack.add(
6667-
// Result expected on stack.
6668-
graph.addConstantNull(closedWorld)
6669-
..sourceInformation = sourceInformation,
6670-
);
6671-
return;
6672-
}
6673-
DartType type = closedWorld.dartTypes.legacyType(
6674-
_elementMap.getDartType(invocation.arguments.types.single),
6675-
);
6676-
push(
6677-
HLoadType.type(type, _abstractValueDomain.dynamicType)
6678-
..sourceInformation = sourceInformation,
6679-
);
6680-
}
6681-
66826654
void _handleForeignCreateJsSentinel(
66836655
ir.StaticInvocation invocation,
66846656
SourceInformation? sourceInformation,

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6115,12 +6115,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
61156115
if (name == 'TYPE_REF') {
61166116
return _emitType(typeArgs.single);
61176117
}
6118-
// TODO(nshahan): Delete after uses are deleted from dart:_rti and the
6119-
// external signature is removed from dart:_foreign_helper.
6120-
if (name == 'LEGACY_TYPE_REF') {
6121-
return _emitType(
6122-
typeArgs.single.withDeclaredNullability(Nullability.legacy));
6123-
}
61246118
}
61256119
}
61266120

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6564,12 +6564,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
65646564
if (name == 'TYPE_REF') {
65656565
return _emitType(typeArgs.single);
65666566
}
6567-
// TODO(nshahan): Delete after uses are deleted from dart:_rti and the
6568-
// external signature is removed from dart:_foreign_helper.
6569-
if (name == 'LEGACY_TYPE_REF') {
6570-
return _emitType(
6571-
typeArgs.single.withDeclaredNullability(Nullability.legacy));
6572-
}
65736567
}
65746568
}
65756569
if (args.length == 1) {

sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,6 @@ external JS_RAW_EXCEPTION();
336336
@notNull
337337
external Rti TYPE_REF<T>();
338338

339-
/// Returns a reference to the internal value that represents [T]*.
340-
///
341-
/// Static calls to this function are inserted directly by the compiler.
342-
@notNull
343-
external Rti LEGACY_TYPE_REF<T>();
344-
345339
/// JavaScript string concatenation. Inputs must be Strings.
346340
@pragma('ddc:trust-inline')
347341
external String JS_STRING_CONCAT(String a, String b);

sdk/lib/_internal/js_runtime/lib/foreign_helper.dart

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,27 +157,30 @@ export 'dart:_array_flags';
157157
/// additional arguments for the new information.
158158
// Add additional optional arguments if needed. The method is treated internally
159159
// as a variable argument method.
160-
external T JS<T>(String typeDescription, String codeTemplate,
161-
[arg0,
162-
arg1,
163-
arg2,
164-
arg3,
165-
arg4,
166-
arg5,
167-
arg6,
168-
arg7,
169-
arg8,
170-
arg9,
171-
arg10,
172-
arg11,
173-
arg12,
174-
arg13,
175-
arg14,
176-
arg51,
177-
arg16,
178-
arg17,
179-
arg18,
180-
arg19]);
160+
external T JS<T>(
161+
String typeDescription,
162+
String codeTemplate, [
163+
arg0,
164+
arg1,
165+
arg2,
166+
arg3,
167+
arg4,
168+
arg5,
169+
arg6,
170+
arg7,
171+
arg8,
172+
arg9,
173+
arg10,
174+
arg11,
175+
arg12,
176+
arg13,
177+
arg14,
178+
arg51,
179+
arg16,
180+
arg17,
181+
arg18,
182+
arg19,
183+
]);
181184

182185
/// Converts the Dart closure [function] into a JavaScript closure.
183186
///
@@ -228,8 +231,22 @@ external JS_EMBEDDED_GLOBAL(String typeDescription, String name);
228231
/// `_js_shared_embedded_names` library.
229232
// Add additional optional arguments if needed. The method is treated internally
230233
// as a variable argument method.
231-
external JS_BUILTIN(String typeDescription, JsBuiltin builtin,
232-
[arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11]);
234+
external JS_BUILTIN(
235+
String typeDescription,
236+
JsBuiltin builtin, [
237+
arg0,
238+
arg1,
239+
arg2,
240+
arg3,
241+
arg4,
242+
arg5,
243+
arg6,
244+
arg7,
245+
arg8,
246+
arg9,
247+
arg10,
248+
arg11,
249+
]);
233250

234251
/// Returns the state of a flag that is determined by the state of the compiler
235252
/// when the program has been analyzed.
@@ -258,9 +275,6 @@ external Object JS_RAW_EXCEPTION();
258275
/// Returns a TypeReference to [T].
259276
external Rti TYPE_REF<T>();
260277

261-
/// Returns a TypeReference to [T]*.
262-
external Rti LEGACY_TYPE_REF<T>();
263-
264278
/// Pretend [code] is executed. Generates no executable code. This is used to
265279
/// model effects at some other point in external code. For example, the
266280
/// following models an assignment to foo with an unknown value.
@@ -336,8 +350,12 @@ external int HArrayFlagsGet(Object array);
336350
/// intervening HArrayFlagsSet that might invalidate the check.
337351
@pragma('dart2js:as:trust')
338352
T HArrayFlagsCheck<T>(
339-
Object array, int arrayFlags, int checkFlags, String operation,
340-
[String verb = 'modify']) {
353+
Object array,
354+
int arrayFlags,
355+
int checkFlags,
356+
String operation, [
357+
String verb = 'modify',
358+
]) {
341359
// This body is unused but serves as a model for global for impacts and
342360
// analysis.
343361
if (arrayFlags & checkFlags != 0) {

sdk/lib/_internal/js_shared/lib/rti.dart

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import 'dart:_foreign_helper'
1616
JS_GET_NAME,
1717
JS_STRING_CONCAT,
1818
RAW_DART_FUNCTION_REF,
19-
TYPE_REF,
20-
LEGACY_TYPE_REF;
19+
TYPE_REF;
2120
import 'dart:_interceptors'
2221
show JavaScriptFunction, JSArray, JSNull, JSUnmodifiableArray;
2322
import 'dart:_js_helper'
@@ -1477,8 +1476,6 @@ Object? _installSpecializedAsCheck(Object? object) {
14771476
bool _nullIs(Rti testRti) {
14781477
int kind = Rti._getKind(testRti);
14791478
return isSoundTopType(testRti) ||
1480-
isLegacyObjectType(testRti) ||
1481-
_Utils.isIdentical(testRti, LEGACY_TYPE_REF<Never>()) ||
14821479
kind == Rti.kindQuestion ||
14831480
kind == Rti.kindStar && _nullIs(Rti._getStarArgument(testRti)) ||
14841481
kind == Rti.kindFutureOr && _nullIs(Rti._getFutureOrArgument(testRti)) ||
@@ -2686,8 +2683,7 @@ class _Universe {
26862683
baseKind == Rti.kindFutureOr &&
26872684
isNullable(Rti._getFutureOrArgument(baseType))) {
26882685
return baseType;
2689-
} else if (baseKind == Rti.kindNever ||
2690-
_Utils.isIdentical(baseType, LEGACY_TYPE_REF<Never>())) {
2686+
} else if (baseKind == Rti.kindNever) {
26912687
return TYPE_REF<Null>();
26922688
} else if (baseKind == Rti.kindStar) {
26932689
Rti starArgument = Rti._getStarArgument(baseType);
@@ -2731,9 +2727,7 @@ class _Universe {
27312727
) {
27322728
if (normalize) {
27332729
int baseKind = Rti._getKind(baseType);
2734-
if (isSoundTopType(baseType) ||
2735-
isObjectType(baseType) ||
2736-
isLegacyObjectType(baseType)) {
2730+
if (isSoundTopType(baseType) || isObjectType(baseType)) {
27372731
return baseType;
27382732
} else if (baseKind == Rti.kindNever) {
27392733
return _lookupFutureRti(universe, baseType);
@@ -4358,7 +4352,7 @@ bool isDefinitelyTopType(Rti t) => isTopType(
43584352

43594353
@pragma('dart2js:parameter:trust')
43604354
bool isTopType(Rti t, bool isLegacy) =>
4361-
isSoundTopType(t) || isLegacyObjectType(t) || isLegacy && isObjectType(t);
4355+
isSoundTopType(t) || isLegacy && isObjectType(t);
43624356

43634357
bool isSoundTopType(Rti t) {
43644358
int kind = Rti._getKind(t);
@@ -4373,8 +4367,6 @@ bool isBottomType(Rti t, bool isLegacy) =>
43734367
Rti._getKind(t) == Rti.kindNever || isLegacy && isNullType(t);
43744368

43754369
bool isObjectType(Rti t) => _Utils.isIdentical(t, TYPE_REF<Object>());
4376-
bool isLegacyObjectType(Rti t) =>
4377-
_Utils.isIdentical(t, LEGACY_TYPE_REF<Object>());
43784370
bool isNullableObjectType(Rti t) => _Utils.isIdentical(t, TYPE_REF<Object?>());
43794371
bool isNullType(Rti t) =>
43804372
_Utils.isIdentical(t, TYPE_REF<Null>()) ||

tests/dartdevc/subtype_test.dart

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Requirements=nnbd-strong
66

7-
import 'dart:_foreign_helper' show LEGACY_TYPE_REF, TYPE_REF;
7+
import 'dart:_foreign_helper' show TYPE_REF;
88
import 'dart:async' show FutureOr;
99

1010
import 'runtime_utils.dart'
@@ -69,31 +69,6 @@ void main() {
6969
// A? <: Object?
7070
checkProperSubtype(TYPE_REF<A?>(), TYPE_REF<Object?>());
7171

72-
// Legacy types will eventually be migrated to T or T? but until then are
73-
// symmetric with both.
74-
// Object* <:> Object
75-
checkMutualSubtype(LEGACY_TYPE_REF<Object>(), TYPE_REF<Object>());
76-
// Object* <:> Object?
77-
checkMutualSubtype(LEGACY_TYPE_REF<Object>(), TYPE_REF<Object?>());
78-
79-
// Bottom Types
80-
// Null <: Object*
81-
checkSubtype(TYPE_REF<Null>(), LEGACY_TYPE_REF<Object>());
82-
// Never <: Object*
83-
checkSubtype(TYPE_REF<Never>(), LEGACY_TYPE_REF<Object>());
84-
// A* <:> A
85-
checkMutualSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<A>());
86-
// A* <:> A?
87-
checkMutualSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<A?>());
88-
// A* <: Object
89-
checkProperSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<Object>());
90-
// A* <: Object?
91-
checkProperSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<Object?>());
92-
// Null <: A*
93-
checkProperSubtype(TYPE_REF<Null>(), LEGACY_TYPE_REF<A>());
94-
// Never <: A*
95-
checkProperSubtype(TYPE_REF<Never>(), LEGACY_TYPE_REF<A>());
96-
9772
// Futures.
9873
// Null <: FutureOr<Object?>
9974
checkProperSubtype(TYPE_REF<Null>(), TYPE_REF<FutureOr<Object?>>());
@@ -268,22 +243,6 @@ void main() {
268243
// C? <: A?
269244
checkProperSubtype(TYPE_REF<C?>(), TYPE_REF<A?>());
270245

271-
// Mixed mode.
272-
// B* <: A
273-
checkProperSubtype(LEGACY_TYPE_REF<B>(), TYPE_REF<A>());
274-
// B* <: A?
275-
checkProperSubtype(LEGACY_TYPE_REF<B>(), TYPE_REF<A?>());
276-
// A* <\: B
277-
checkSubtypeFailure(LEGACY_TYPE_REF<A>(), TYPE_REF<B>());
278-
// B? <: A*
279-
checkProperSubtype(TYPE_REF<B?>(), LEGACY_TYPE_REF<A>());
280-
// B <: A*
281-
checkProperSubtype(TYPE_REF<B>(), LEGACY_TYPE_REF<A>());
282-
// A <: B*
283-
checkSubtypeFailure(TYPE_REF<A>(), LEGACY_TYPE_REF<B>());
284-
// A? <: B*
285-
checkSubtypeFailure(TYPE_REF<A?>(), LEGACY_TYPE_REF<B>());
286-
287246
// Allowed in weak mode.
288247
// dynamic <\: Object
289248
checkSubtypeFailure(TYPE_REF<dynamic>(), TYPE_REF<Object>());

tests/dartdevc/subtype_weak_test.dart

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Requirements=nnbd-weak
66

7-
import 'dart:_foreign_helper' show LEGACY_TYPE_REF, TYPE_REF;
7+
import 'dart:_foreign_helper' show TYPE_REF;
88
import 'dart:async';
99

1010
import 'runtime_utils.dart'
@@ -69,31 +69,6 @@ void main() {
6969
// A? <: Object?
7070
checkProperSubtype(TYPE_REF<A?>(), TYPE_REF<Object?>());
7171

72-
// Legacy types will eventually be migrated to T or T? but until then are
73-
// symmetric with both.
74-
// Object* <:> Object
75-
checkMutualSubtype(LEGACY_TYPE_REF<Object>(), TYPE_REF<Object>());
76-
// Object* <:> Object?
77-
checkMutualSubtype(LEGACY_TYPE_REF<Object>(), TYPE_REF<Object?>());
78-
79-
// Bottom Types
80-
// Null <: Object*
81-
checkSubtype(TYPE_REF<Null>(), LEGACY_TYPE_REF<Object>());
82-
// Never <: Object*
83-
checkSubtype(TYPE_REF<Never>(), LEGACY_TYPE_REF<Object>());
84-
// A* <:> A
85-
checkMutualSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<A>());
86-
// A* <:> A?
87-
checkMutualSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<A?>());
88-
// A* <: Object
89-
checkProperSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<Object>());
90-
// A* <: Object?
91-
checkProperSubtype(LEGACY_TYPE_REF<A>(), TYPE_REF<Object?>());
92-
// Null <: A*
93-
checkProperSubtype(TYPE_REF<Null>(), LEGACY_TYPE_REF<A>());
94-
// Never <: A*
95-
checkProperSubtype(TYPE_REF<Never>(), LEGACY_TYPE_REF<A>());
96-
9772
// Futures.
9873
// Null <: FutureOr<Object?>
9974
checkProperSubtype(TYPE_REF<Null>(), TYPE_REF<FutureOr<Object?>>());
@@ -268,22 +243,6 @@ void main() {
268243
// C? <: A?
269244
checkProperSubtype(TYPE_REF<C?>(), TYPE_REF<A?>());
270245

271-
// Mixed mode.
272-
// B* <: A
273-
checkProperSubtype(LEGACY_TYPE_REF<B>(), TYPE_REF<A>());
274-
// B* <: A?
275-
checkProperSubtype(LEGACY_TYPE_REF<B>(), TYPE_REF<A?>());
276-
// A* <\: B
277-
checkSubtypeFailure(LEGACY_TYPE_REF<A>(), TYPE_REF<B>());
278-
// B? <: A*
279-
checkProperSubtype(TYPE_REF<B?>(), LEGACY_TYPE_REF<A>());
280-
// B <: A*
281-
checkProperSubtype(TYPE_REF<B>(), LEGACY_TYPE_REF<A>());
282-
// A <: B*
283-
checkSubtypeFailure(TYPE_REF<A>(), LEGACY_TYPE_REF<B>());
284-
// A? <: B*
285-
checkSubtypeFailure(TYPE_REF<A?>(), LEGACY_TYPE_REF<B>());
286-
287246
// Allowed in weak mode.
288247
// dynamic <: Object
289248
checkSubtype(TYPE_REF<dynamic>(), TYPE_REF<Object>());

0 commit comments

Comments
 (0)