-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2wasm] Use TFA-inferred types also for static fields
Currently the type of a static field is only based on the dart type, not inferred types. This can mean that the type of such field is e.g. `dynamic`. Though the return type of the initializer function used the unboxing information. => There was an invariant that if we use `null` to signal uninitialized in the global, then calling the initializer will also result in a non-nullable reference type. => This was invariant was broken by recent changes to dart2wasm that take advantage of TFA-inferred unboxing information. => We fix this inconsistency by ensuring the wasm global's type is the same as the initializer function's return type. Change-Id: I9c27c0b28d2f81f888b4c9afc59dad42af2229ab Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365825 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
- Loading branch information
1 parent
31eb496
commit 3dfee27
Showing
3 changed files
with
60 additions
and
22 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
24 changes: 24 additions & 0 deletions
24
tests/web/wasm/lazy_static_number_initializer_regression_test.dart
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,24 @@ | ||
// 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. | ||
|
||
import 'dart:math'; | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
final num maxInt = 1 is double ? pow(2, 52) : 1.0e300.floor(); | ||
|
||
dynamic round(dynamic number) { | ||
if (number is num) { | ||
if (number.isInfinite) { | ||
return maxInt; | ||
} | ||
return number.round(); | ||
} | ||
return number; | ||
} | ||
|
||
main() { | ||
Expect.equals(round(1.0), 1); | ||
Expect.equals(round(1), 1); | ||
} |