From 2dffe31edd413b39f024cf3d5a1c4335fdb674a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 21 Dec 2022 11:09:22 +0000 Subject: [PATCH] [dart2wasm] Override _BoxedBool runtime type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Continuation of 181c996. Overriding `_BoxedBool` runtime type turned out to be a bit tricky, as explained in comments. New passing tests: - co19/Language/Expressions/Booleans/runtime_type_t01 - co19/LanguageFeatures/Enhanced-Enum/semantics_A07_t01 - language/type_object/first_class_types_literals_runtime_1_test - language/type_object/first_class_types_literals_runtime_2_test - language/type_object/first_class_types_literals_runtime_test Change-Id: Icdd3eb61989298f70bfd6dca42a029fcc1ae9ec2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276502 Reviewed-by: Aske Simon Christensen Commit-Queue: Ömer Ağacan --- sdk/lib/_internal/wasm/lib/bool.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sdk/lib/_internal/wasm/lib/bool.dart b/sdk/lib/_internal/wasm/lib/bool.dart index 2aeab66110e..a949961f405 100644 --- a/sdk/lib/_internal/wasm/lib/bool.dart +++ b/sdk/lib/_internal/wasm/lib/bool.dart @@ -4,6 +4,18 @@ part of "core_patch.dart"; +@patch +class bool { + // Note: this needs to be in `bool`, cannot be overridden in `_BoxedBool`. I + // suspect the problem is there's an assumption in the front-end that `bool` + // has one implementation class (unlike `double`, `int`, `String`) which is + // the `bool` class itself. So when `runtimeType` is not overridden in + // `bool`, in code like `x.runtimeType` where `x` is `bool`, direct call + // metadata says that the member is `Object.runtimeType`. + @override + Type get runtimeType => bool; +} + @pragma("wasm:entry-point") class _BoxedBool extends bool { // A boxed bool contains an unboxed bool.