Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_rti.dart

Issue 2722753002: Remove HRuntimeType implementation (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/js_runtime/lib/js_rti.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_rti.dart b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
index 8f27e957b360d0e6be4878834a6540eca1eb69d6..8ee404e4496207cb02cd657fac502177c8506476 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_rti.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_rti.dart
@@ -371,23 +371,21 @@ String computeTypeName(String isField, List arguments) {
}
Object subtypeCast(Object object, String isField, List checks, String asField) {
- if (object != null && !checkSubtype(object, isField, checks, asField)) {
- String actualType = Primitives.objectTypeName(object);
- String typeName = computeTypeName(isField, checks);
- // TODO(johnniwinther): Move type lookup to [CastErrorImplementation] to
- // align with [TypeErrorImplementation].
- throw new CastErrorImplementation(actualType, typeName);
- }
- return object;
-}
-
-Object assertSubtype(Object object, String isField, List checks,
- String asField) {
- if (object != null && !checkSubtype(object, isField, checks, asField)) {
- String typeName = computeTypeName(isField, checks);
- throw new TypeErrorImplementation(object, typeName);
- }
- return object;
+ if (object == null) return object;
+ if (checkSubtype(object, isField, checks, asField)) return object;
+ String actualType = Primitives.objectTypeName(object);
+ String typeName = computeTypeName(isField, checks);
+ // TODO(johnniwinther): Move type lookup to [CastErrorImplementation] to
+ // align with [TypeErrorImplementation].
+ throw new CastErrorImplementation(actualType, typeName);
+}
+
+Object assertSubtype(
+ Object object, String isField, List checks, String asField) {
+ if (object == null) return object;
+ if (checkSubtype(object, isField, checks, asField)) return object;
+ String typeName = computeTypeName(isField, checks);
+ throw new TypeErrorImplementation(object, typeName);
}
/// Checks that the type represented by [subtype] is a subtype of [supertype].

Powered by Google App Engine
This is Rietveld 408576698