-
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.
[vm, dart2wasm, tfa] Do not infer nullable return type when static ty…
…pe is non-nullable With sound null safety, implicit "return null" at the end of function should be taken into account only if return type is nullable. TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter148617.dart Issue: flutter/flutter#148617 Change-Id: I209fc9a3b10639fd4024d4b1807591498349e1f0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367980 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
- Loading branch information
1 parent
8c26c35
commit 345b437
Showing
12 changed files
with
81 additions
and
33 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
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
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
12 changes: 6 additions & 6 deletions
12
pkg/vm/testcases/transformations/type_flow/summary_collector/control_flow.dart.expect
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
2 changes: 1 addition & 1 deletion
2
...vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart.expect
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
6 changes: 3 additions & 3 deletions
6
pkg/vm/testcases/transformations/type_flow/summary_collector/setter_result.dart.expect
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
4 changes: 2 additions & 2 deletions
4
pkg/vm/testcases/transformations/type_flow/summary_collector/vars.dart.expect
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
21 changes: 21 additions & 0 deletions
21
pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter148617.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,21 @@ | ||
// 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. | ||
|
||
// Regression test for https://github.com/flutter/flutter/issues/148617. | ||
// Verifies that TFA should not infer nullable return type if | ||
// static return type is non-nullable. | ||
|
||
int foo() => int.parse('1'); | ||
|
||
int bar() { | ||
try { | ||
return foo(); | ||
} catch (e, st) { | ||
Error.throwWithStackTrace(e, st); | ||
} | ||
} | ||
|
||
main() { | ||
print(bar()); | ||
} |
25 changes: 25 additions & 0 deletions
25
pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter148617.dart.expect
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,25 @@ | ||
library #lib; | ||
import self as self; | ||
import "dart:core" as core; | ||
|
||
|
||
[@vm.inferred-return-type.metadata=int] | ||
[@vm.unboxing-info.metadata=()->i] | ||
static method foo() → core::int | ||
return [@vm.inferred-type.metadata=int] core::int::parse("1"); | ||
|
||
[@vm.inferred-return-type.metadata=int] | ||
[@vm.unboxing-info.metadata=()->i] | ||
static method bar() → core::int { | ||
try { | ||
return [@vm.inferred-type.metadata=int] self::foo(); | ||
} | ||
on core::Object catch(final core::Object e, final core::StackTrace st) { | ||
core::Error::throwWithStackTrace(e, st); | ||
} | ||
} | ||
|
||
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)] | ||
static method main() → dynamic { | ||
core::print([@vm.inferred-type.metadata=int] self::bar()); | ||
} |