|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +/// Compile the exact same source file into 2 different modules. |
| 5 | +// RUN: %target-swift-frontend -emit-module -o %t/A.swiftmodule %t/Lib.swift \ |
| 6 | +// RUN: -emit-module-source-info -module-name A -package-name pkg \ |
| 7 | +// RUN: -enable-testing |
| 8 | +// RUN: %target-swift-frontend -emit-module -o %t/B.swiftmodule %t/Lib.swift \ |
| 9 | +// RUN: -emit-module-source-info -module-name B -package-name pkg \ |
| 10 | +// RUN: -enable-testing |
| 11 | + |
| 12 | +// Build a client importing both modules and hitting the ambiguities. |
| 13 | +// RUN: not %target-swift-frontend -typecheck -I %t %t/Client.swift -package-name pkg 2> %t/out |
| 14 | +// RUN: cat %t/out | %FileCheck %s |
| 15 | + |
| 16 | +//--- Lib.swift |
| 17 | +public func publicAmbiguity() {} |
| 18 | +package func packageAmbiguity() {} |
| 19 | +internal func internalAmbiguity() {} |
| 20 | + |
| 21 | +//--- Client.swift |
| 22 | +@testable import A |
| 23 | +@testable import B |
| 24 | + |
| 25 | +func foo() { |
| 26 | + publicAmbiguity() |
| 27 | +// CHECK: error: ambiguous use of 'publicAmbiguity()' |
| 28 | +// CHECK-NEXT: publicAmbiguity() |
| 29 | +// CHECK-NEXT: ^ |
| 30 | +// CHECK-NEXT: Lib.swift:1:13: note: found this candidate in module 'A' |
| 31 | +// CHECK-NEXT: public func publicAmbiguity() {} |
| 32 | +// CHECK-NEXT: ^ |
| 33 | +// CHECK-NEXT: Lib.swift:1:13: note: found this candidate in module 'B' |
| 34 | +// CHECK-NEXT: public func publicAmbiguity() {} |
| 35 | +// CHECK-NEXT: ^ |
| 36 | + |
| 37 | + packageAmbiguity() |
| 38 | +// CHECK: error: ambiguous use of 'packageAmbiguity()' |
| 39 | +// CHECK-NEXT: packageAmbiguity() |
| 40 | +// CHECK-NEXT: ^ |
| 41 | +// CHECK-NEXT: Lib.swift:2:14: note: found this candidate in module 'A' |
| 42 | +// CHECK-NEXT: package func packageAmbiguity() {} |
| 43 | +// CHECK-NEXT: ^ |
| 44 | +// CHECK-NEXT: Lib.swift:2:14: note: found this candidate in module 'B' |
| 45 | +// CHECK-NEXT: package func packageAmbiguity() {} |
| 46 | +// CHECK-NEXT: ^ |
| 47 | + |
| 48 | + internalAmbiguity() |
| 49 | +// CHECK: error: ambiguous use of 'internalAmbiguity()' |
| 50 | +// CHECK-NEXT: internalAmbiguity() |
| 51 | +// CHECK-NEXT: ^ |
| 52 | +// CHECK-NEXT: Lib.swift:3:15: note: found this candidate in module 'A' |
| 53 | +// CHECK-NEXT: internal func internalAmbiguity() {} |
| 54 | +// CHECK-NEXT: ^ |
| 55 | +// CHECK-NEXT: Lib.swift:3:15: note: found this candidate in module 'B' |
| 56 | +// CHECK-NEXT: internal func internalAmbiguity() {} |
| 57 | +// CHECK-NEXT: ^ |
| 58 | +} |
0 commit comments