[VM/runtime] Fix type test: a closure is T, when T is instantiated to Object.

Fixes https://github.com/dart-lang/sdk/issues/46165

TEST=added regression test

Change-Id: I3016f60560b00f077d5ef55a0b23ccfb7dbf0836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201863
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
This commit is contained in:
Regis Crelier 2021-06-01 20:25:55 +00:00 committed by commit-bot@chromium.org
parent 7af28d8274
commit 7014f03aad
3 changed files with 22 additions and 1 deletions

View file

@ -18151,7 +18151,7 @@ void SubtypeTestCache::WriteCurrentEntryToBuffer(
} else {
ASSERT(instance_class_id_or_signature.IsFunctionType());
buffer->Printf(
"%sfunction: %s", separator,
"%ssignature: %s", separator,
FunctionType::Cast(instance_class_id_or_signature).ToCString());
}
if (!destination_type.IsNull()) {
@ -19237,6 +19237,7 @@ bool Instance::RuntimeTypeIsSubtypeOf(
instantiated_other = TypeRef::Cast(instantiated_other).type();
}
if (instantiated_other.IsTopTypeForSubtyping() ||
instantiated_other.IsObjectType() ||
instantiated_other.IsDartFunctionType()) {
return true;
}

View file

@ -0,0 +1,10 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
void main() {
final l = <Object>[];
l.add((String x, StringBuffer y) {
print(x);
});
}

View file

@ -0,0 +1,10 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
void main() {
final l = <Object>[];
l.add((String x, StringBuffer y) {
print(x);
});
}