-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2wasm] Fix instantiation context types in instantiation trampolines
Type for a closure with one argument (Closure-0-1) is subtype of type of a closure with no arguments (Closure-0-0). This allows calling the closure with no arguments in the generated code. (This only happens when the Dart types align, i.e. the argument is optional) However instantiation vtable functions for e.g. Closure-1-1 currently can't be as Closure-1-0, resulting in a type cast error in a code like: void test<T>([T? x]) {} void Function() x = runtimeTrue ? test : () {}; x(); Relax the instantiation context struct type in instantiation vtable functions and downcast the generic closure struct type (type of the instantiation closure) to the right type before calling instantiation clsoure. Fixes #56534. Change-Id: I59f9b019c4dc8d2e26ee21f1f6c3c607af0be4d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381641 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
- Loading branch information
Showing
3 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
bool get runtimeTrue => int.parse('1') == 1; | ||
|
||
void test<T>([T? x]) {} | ||
|
||
void main() { | ||
void Function() x = runtimeTrue ? test : () {}; | ||
x(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
bool get runtimeTrue => int.parse('1') == 1; | ||
|
||
class C { | ||
void test<T>([T? x]) {} | ||
} | ||
|
||
void main() { | ||
final c = C(); | ||
void Function() x = runtimeTrue ? c.test : () {}; | ||
x(); | ||
} |