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

Unified Diff: runtime/vm/object.cc

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Update Kernel code. Created 3 years, 7 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
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index e00640e3ab021ababcfcce05b187fa01b2f23252..a6ba79ffd30daf4695c7a0ed0c9d35acc87397cd 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -3820,7 +3820,6 @@ bool Class::TypeTestNonRecursive(const Class& cls,
Zone* zone = Thread::Current()->zone();
Class& thsi = Class::Handle(zone, cls.raw());
while (true) {
- ASSERT(!thsi.IsVoidClass());
// Check for DynamicType.
// Each occurrence of DynamicType in type T is interpreted as the dynamic
// type, a supertype of all types.
@@ -3839,10 +3838,15 @@ bool Class::TypeTestNonRecursive(const Class& cls,
return test_kind == Class::kIsSubtypeOf;
}
// Check for ObjectType. Any type that is not NullType or DynamicType
- // (already checked above), is more specific than ObjectType.
- if (other.IsObjectClass()) {
+ // (already checked above), is more specific than ObjectType/VoidType.
+ if (other.IsObjectClass() || other.IsVoidClass()) {
return true;
}
+ // If other is neither Object, dynamic or void, then ObjectType/VoidType
+ // can't be a subtype of other.
+ if (thsi.IsObjectClass() || thsi.IsVoidClass()) {
+ return false;
+ }
// Check for reflexivity.
if (thsi.raw() == other.raw()) {
const intptr_t num_type_params = thsi.NumTypeParameters();
@@ -15830,7 +15834,7 @@ bool Instance::IsInstanceOf(
ASSERT(!other.IsMalformed());
ASSERT(!other.IsMalbounded());
if (other.IsVoidType()) {
- return false;
+ return true;
}
Zone* zone = Thread::Current()->zone();
const Class& cls = Class::Handle(zone, clazz());
@@ -16648,9 +16652,12 @@ bool AbstractType::TypeTest(TypeTestKind test_kind,
return false;
}
// Any type is a subtype of (and is more specific than) Object and dynamic.
+ // As of Dart 1.24, void is dynamically treated like Object (except when
+ // comparing function-types).
// As of Dart 1.5, the Null type is a subtype of (and is more specific than)
// any type.
- if (other.IsObjectType() || other.IsDynamicType() || IsNullType()) {
+ if (other.IsObjectType() || other.IsDynamicType() || other.IsVoidType() ||
+ IsNullType()) {
return true;
}
Zone* zone = Thread::Current()->zone();
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698