-
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.
Use promoted type to infer for-each iterables.
Fixes #42653. Change-Id: I90319b775207e6cc1c6b7a79d29b2c237b750845 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162625 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Paul Berry <[email protected]>
- Loading branch information
1 parent
8cc4a12
commit 0eec9ee
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/bug42653.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,39 @@ | ||
// Copyright (c) 2020, 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. | ||
|
||
void forEachStatement(Object x) { | ||
if (x is int) { | ||
/*int*/ x; | ||
for (x in [0]) { | ||
/*int*/ x; | ||
} | ||
} | ||
} | ||
|
||
forEachElementInListLiteral(Object x) { | ||
if (x is int) { | ||
/*int*/ x; | ||
return [ | ||
for (x in [0]) /*int*/ x | ||
]; | ||
} | ||
} | ||
|
||
forEachElementInMapLiteral(Object x) { | ||
if (x is int) { | ||
/*int*/ x; | ||
return { | ||
for (x in [0]) /*int*/ x: /*int*/ x | ||
}; | ||
} | ||
} | ||
|
||
forEachElementInSetLiteral(Object x) { | ||
if (x is int) { | ||
/*int*/ x; | ||
return { | ||
for (x in [0]) /*int*/ 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
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