|
| 1 | +// RUN: split-file %s %t |
| 2 | +// RUN: %target-swift-frontend -typecheck -verify -I %t/Cxx/include %t/PrivateFile.swift -cxx-interoperability-mode=default -module-name Module |
| 3 | +// RUN: %target-swift-frontend -typecheck -verify -I %t/Cxx/include %t/HasRetroactive.swift -cxx-interoperability-mode=default -module-name Module |
| 4 | +// RUN: %target-swift-frontend -typecheck -verify -I %t/Cxx/include %t/NoRetroactive.swift -cxx-interoperability-mode=default -module-name Module |
| 5 | + |
| 6 | +//--- Cxx/include/module.modulemap |
| 7 | +module CxxModule { |
| 8 | + requires cplusplus |
| 9 | + header "cxx-header.h" |
| 10 | +} |
| 11 | + |
| 12 | +//--- Cxx/include/cxx-header.h |
| 13 | +#pragma once |
| 14 | + |
| 15 | +#define SWIFT_PRIVATE_FILEID(_fileID) \ |
| 16 | + __attribute__((swift_attr("private_fileid:" _fileID))) |
| 17 | + |
| 18 | +class SWIFT_PRIVATE_FILEID("Module/PrivateFile.swift") Foo { void privateMethod(void) const {} }; |
| 19 | + |
| 20 | +//--- PrivateFile.swift |
| 21 | +import CxxModule |
| 22 | + |
| 23 | +extension Foo : ExpressibleByIntegerLiteral { |
| 24 | + public typealias IntegerLiteralType = Int |
| 25 | + public init(integerLiteral: Self.IntegerLiteralType) { |
| 26 | + self.init() |
| 27 | + self.privateMethod() |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +//--- HasRetroactive.swift |
| 32 | +import CxxModule |
| 33 | + |
| 34 | +extension Foo : @retroactive ExpressibleByIntegerLiteral { |
| 35 | + public typealias IntegerLiteralType = Int |
| 36 | + public init(integerLiteral: Self.IntegerLiteralType) { |
| 37 | + self.init() |
| 38 | + self.privateMethod() // expected-error {{'privateMethod' is inaccessible due to 'private' protection level}} |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +//--- NoRetroactive.swift |
| 43 | +import CxxModule |
| 44 | + |
| 45 | +// expected-warning@+2 {{extension declares a conformance of imported type 'Foo' to imported protocol 'ExpressibleByIntegerLiteral'}} |
| 46 | +// expected-note@+1 {{add '@retroactive' to silence this warning}} |
| 47 | +extension Foo : ExpressibleByIntegerLiteral { |
| 48 | + public typealias IntegerLiteralType = Int |
| 49 | + public init(integerLiteral: Self.IntegerLiteralType) { |
| 50 | + self.init() |
| 51 | + self.privateMethod() // expected-error {{'privateMethod' is inaccessible due to 'private' protection level}} |
| 52 | + } |
| 53 | +} |
0 commit comments