Skip to content

Overloading on borrowing/consuming results in ambiguities with performance hacks removed  #77001

Open
@xedin

Description

@xedin

Description

One of the test-cases introduced by #76834 depends on a type-checker hack that applies only to initializers - https://github.com/swiftlang/swift/blob/main/lib/Sema/CSSimplify.cpp#L9843-L9855. Removal of this hack makes the code ambiguous.

Reproduction

struct View : ~Escapable {
 init(_ otherBV: borrowing View) {}
 init(_ k: consuming View) {}
}

@lifetime(x)
func getConsumingView(_ x: consuming View) -> View {
  return View(x)
}

Without perf hack this produces:

 error: ambiguous use of 'init(_:)'

Expected behavior

We need to define expected type/flag matching behavior for borrowing and consuming parameters that does not depend on the performance hack(s).

Environment

Swift compiler main branch.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.ownershipFeature: Ownership modifiers and semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions