forked from dart-lang/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2wasm] Fix missing type check in implicit field setters if field…
… is covariant For a class like this: class A<T> { T? value; } the implicit setter function (`A.value=`) has to check the argument type. TEST=language/covariant_field_implicit_setter_test Change-Id: Ie990b79f631275fb0a7c88ec7d7dd3a82a784148 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381000 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
- Loading branch information
1 parent
534d3ff
commit e5704ea
Showing
3 changed files
with
73 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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 'package:expect/expect.dart'; | ||
import 'package:expect/variations.dart'; | ||
|
||
main() { | ||
final List<A<Object>> l = [A<int>(), A<String>()]; | ||
|
||
final aInt = l[int.parse('0')]; | ||
Expect.isNull(aInt.value); | ||
aInt.value = 10; | ||
Expect.equals(10, aInt.value); | ||
|
||
final aString = l[int.parse('1')]; | ||
Expect.isNull(aString.value); | ||
if (checkedParameters) { | ||
Expect.throws(() => aString.value = 1); | ||
Expect.isNull(aString.value); | ||
} | ||
} | ||
|
||
class A<T> { | ||
T? value; | ||
} |