yairm210/Unciv

Coders: deprecated getX helpers with forEachX replacements may break functionality if used blindly

クローズ

#14,921 opened on 2026/05/24

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Kotlin (1,903 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (11,096 個のスター)
PR merge metrics
 (平均マージ 3d 6h) (30d で 80 merged PRs)

説明

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.

コントリビューターガイド