Coders: deprecated getX helpers with forEachX replacements may break functionality if used blindly
#14921 opened on May 24, 2026
Description
Game Version
5eecbdb
Describe the bug
@Ambeco - your newly introduced (#14724) forEach* functions have at last one pitfall. See Steps. I assume using the other overload would solve that, but haven't tested so far - it's still a pitfall because from the call site it looks entirely equivalent.
Steps to Reproduce
1: Replace: https://github.com/yairm210/Unciv/blob/93ac3d8ae984c53a52952e99e1a91b62cad14850/core/src/com/unciv/logic/city/managers/CityExpansionManager.kt#L133-L135 ...with:
city.getCenterTile().forEachTileInDistance(1) { tile ->
if (tile.getCity() == null)
takeOwnership(tile)
}
2: Run and found city 3: See it only owns its center tile - the first iteration somehow will abort the loop once it sees the first-checked tile is already owned...
Operating System
Linux
Additional Information
These ReplaceWith definitions are necessarily bad, since automatic application by the IDE will never result in working code. Can't be helped because the changes need to begin before the actual call. These things can be written with surprising intelligence to help that IDE auto-fix, but replacement will always begin with the function name and end with the closing ) of the parameter list. Can't change receiver or append lambdas.