Skip to content

Commit d33e94f

Browse files
nshahanCommit Bot
authored andcommitted
[ddc] Migrate js_typerep libraries to null safety
Change-Id: I73a1f7da1c62bc12d832da7d22a5288425ee99aa Issue: #46617 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223362 Reviewed-by: Mark Zhou <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent b628d00 commit d33e94f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/// An abstraction of the JS types
2-
3-
// @dart = 2.9
1+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
44

5+
/// An abstraction of the JS types
56
abstract class JSType {
67
const JSType();
78

@@ -20,7 +21,7 @@ abstract class JSType {
2021
bool get isFalsey;
2122

2223
/// The JS `typeof` value, if unambiguous.
23-
String get primitiveTypeOf => null;
24+
String? get primitiveTypeOf => null;
2425

2526
static const jsBoolean = JSBoolean();
2627
static const jsNumber = JSNumber();

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'package:kernel/class_hierarchy.dart';
86
import 'package:kernel/core_types.dart';
97
import 'package:kernel/kernel.dart';
108
import 'package:kernel/type_environment.dart';
9+
1110
import '../compiler/js_typerep.dart';
1211
import 'kernel_helpers.dart';
1312

@@ -32,9 +31,8 @@ class JSTypeRep extends SharedJSTypeRep<DartType> {
3231
@override
3332
JSType typeFor(DartType type) {
3433
while (type is TypeParameterType) {
35-
type = (type as TypeParameterType).parameter.bound;
34+
type = type.parameter.bound;
3635
}
37-
if (type == null) return JSType.jsUnknown;
3836
assert(isKnownDartTypeImplementor(type));
3937

4038
// Note that this should be changed if Dart gets non-nullable types
@@ -65,11 +63,12 @@ class JSTypeRep extends SharedJSTypeRep<DartType> {
6563
return JSType.jsObject;
6664
}
6765

68-
/// Given a Dart type return the known implementation type, if any.
69-
/// Given `bool`, `String`, or `num`/`int`/`double`,
70-
/// returns the corresponding class in `dart:_interceptors`:
71-
/// `JSBool`, `JSString`, and `JSNumber` respectively, otherwise null.
72-
Class getImplementationClass(DartType t) {
66+
/// Returns the known implementation type for [t], if any.
67+
///
68+
/// Given `bool`, `String`, or `num`/`int`/`double`, returns the corresponding
69+
/// class in `dart:_interceptors`: `JSBool`, `JSString`, and `JSNumber`
70+
/// respectively, otherwise null.
71+
Class? getImplementationClass(DartType t) {
7372
var rep = typeFor(t);
7473
// Number, String, and Bool are final
7574
if (rep == JSType.jsNumber) return _jsNumber;

0 commit comments

Comments
 (0)