mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When importing a C++ struct that contains two methods that only differ in const-ness, we append `Mutating` to the name of the non-const method to make it possible to call from Swift unambiguously. Unfortunately that logic was dependent on the order in which we import methods of a class: the `Mutating` suffix was added when another method with the same name was already imported. This caused lookup failures, and the behavior was incorrect when the pair of methods return instances of an unsafe type: the const overload was renamed as `Unsafe` properly, but the non-const overload was not renamed.
23 lines
999 B
Swift
23 lines
999 B
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=AmbiguousMethods -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
|
|
|
|
// CHECK: func increment(_ a: Int32) -> Int32
|
|
// CHECK: mutating func incrementMutating(_ a: Int32) -> Int32
|
|
|
|
// CHECK: mutating func incrementMutating(_ a: Int32, _ b: Int32, _ c: inout Int32)
|
|
// CHECK: func increment(_ a: Int32, _ b: Int32, _ c: inout Int32)
|
|
|
|
// CHECK: mutating func incrementMutating(_ a: inout Int32, _ b: Int32)
|
|
// CHECK: func increment(_ a: inout Int32, _ b: Int32)
|
|
|
|
// CHECK: func numberOfMutableMethodsCalled() -> Int32
|
|
// CHECK: mutating func numberOfMutableMethodsCalledMutating() -> Int32
|
|
|
|
// CHECK: struct HasAmbiguousMethods2
|
|
// CHECK: func increment(_ a: Int32) -> Int32
|
|
// CHECK-NOT: mutating func incrementMutating(_ a: Int32) -> Int32
|
|
|
|
// CHECK: struct HasAmbiguousUnsafeMethods {
|
|
// CHECK: func __getUnsafeUnsafe() -> Unsafe
|
|
// CHECK: mutating func __getUnsafeMutatingUnsafe() -> Unsafe
|
|
// CHECK: }
|