Skip to content

Inconsistent type of userInfo across operating systems in JSONEncoder, JSONDecoder, PropertyListEncoder, PropertyListDecoder #1515

@tothambrus11

Description

@tothambrus11

Description

In MacOS 14, the userInfo property in the protocols mentoned above has the type [CodingUserInfoKey : Any]. However, on MacOS 15, this is changed to [CodingUserInfoKey : any Sendable]. The documentation doesn't disclose any changes to the api over time, just shows the any Sendable version.

This change is particularly nasty because it appears when upgrading operating systems without changing the Package.swift's platforms entry from .macOS(.v14) to .macOS(.v15), so some colleagues who have a newer laptop cannot compile our code, but those on earlier macOS versions can.

We would be also happy to migrate to the latest API, but that doesn't work on Linux and Windows using Swift 6.1. However, it is consistent and works using Swift 6.2.

Reproduction

Swift 6.1 reproduction of problem: https://godbolt.org/z/cEbfbz1x7
Same code using 6.2 works: https://godbolt.org/z/K5Wdzed7e

Expected behavior

  • Have userInfo: [CodingUserInfoKey : Any] iff macos version in Package.swift<= 14
  • Have userInfo: [CodingUserInfoKey : any Sendable] iff macos version in Package.swift >= 15

Environment

My local installation on Windows where it's inconsistent with macos 15:

Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: x86_64-unknown-windows-msvc

My linux installation in a devcontainer where it's also inconsistent with macos 15:

Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

FoundationEssentials.swiftinterface.txt
Let me know if there is any additional information needed. The issue presents itself as the FoundationEssentials.swiftinterface containing the old Any version on Windows and Linux, so I attached the swiftinterface file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions