Skip to content

incorrect warning "'nonisolated(unsafe)' has no effect on property, consider using 'nonisolated'" #81962

Open
@lukaskollmer

Description

@lukaskollmer

Description

the program below compiles fine, but with a warning saying that "'nonisolated(unsafe)' has no effect on property 'value', consider using 'nonisolated'".

this is false: replacing the nonisolated(unsafe) with just nonisolated will result in the compiler (correctly) rejecting the program.

Reproduction

import Observation

@Observable
final class Foo: Sendable {
    nonisolated(unsafe) var value: Int? // warning: 'nonisolated(unsafe)' has no effect on property 'value', consider using 'nonisolated'
}

Expected behavior

the compiler should not emit this warning for this program

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0

Additional information

removing the @Observable macro causes the warning to disappear

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions