Skip to content

nonmutating accessors in conditionally ~Copyable protocol extension error when built with -enable-testing #84015

@jamieQ

Description

@jamieQ

Description

see title

Reproduction

// compile with swiftc -enable-testing ...

protocol Fooable: ~Copyable { }

struct Foo: Fooable, ~Copyable {
    
    //  Compiles
    
    var value: Int {
        nonmutating get { 0 }
        nonmutating set { }
    }
    
}

extension Fooable where Self: ~Copyable {
    
    //  Fails to compile:
    //  "Copy of noncopyable typed value.
    //  This is a compiler bug.
    //  Please file a bug with a small example of the bug"
    
    var valueTwo: Int {
        nonmutating get { 0 }
        nonmutating set { }
    }
    
}

Expected behavior

the code should compile regardless of whether -enable-testing is applied

Environment

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

Additional information

godbolt: https://swift.godbolt.org/z/E5qo9ob5f

originally reported via forum post by Matt Curtis: https://forums.swift.org/t/nonmutating-set-treated-differently-in-protocol-extension/81854

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