|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -emit-module -o %t %t/lib.swift |
| 5 | +// RUN: %target-swift-frontend -typecheck -primary-file %t/main.swift %t/other.swift -I %t -verify -enable-upcoming-feature MemberImportVisibility |
| 6 | + |
| 7 | +// REQUIRES: swift_feature_MemberImportVisibility |
| 8 | + |
| 9 | +//--- main.swift |
| 10 | + |
| 11 | +import Swift |
| 12 | +// expected-note 15 {{add import of module 'lib'}} |
| 13 | + |
| 14 | +for _ in makeSequence() { } |
| 15 | +// expected-error@-1 {{instance method 'makeIterator()' is not available due to missing import of defining module 'lib'}} |
| 16 | +// expected-error@-2 {{instance method 'next()' is not available due to missing import of defining module 'lib'}} |
| 17 | + |
| 18 | +takesNilExpressible(nil) |
| 19 | +// expected-error@-1 {{initializer 'init(nilLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 20 | + |
| 21 | +takesIntExpressible(1) |
| 22 | +// expected-error@-1 {{initializer 'init(integerLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 23 | + |
| 24 | +takesFloatExpressible(1.0) |
| 25 | +// expected-error@-1 {{initializer 'init(floatLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 26 | + |
| 27 | +takesBoolExpressible(true) |
| 28 | +// expected-error@-1 {{initializer 'init(booleanLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 29 | + |
| 30 | +takesUnicodeScalarExpressible("🐦") |
| 31 | +// expected-error@-1 {{initializer 'init(unicodeScalarLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 32 | + |
| 33 | +takesExtendedGraphemeClusterExpressible("🦸🏾♀️") |
| 34 | +// expected-error@-1 {{initializer 'init(extendedGraphemeClusterLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 35 | + |
| 36 | +takesStringLiteralExpressible("Hello world") |
| 37 | +// expected-error@-1 {{initializer 'init(stringLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 38 | + |
| 39 | +takesArrayExpressible([1]) |
| 40 | +// expected-error@-1 {{initializer 'init(arrayLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 41 | + |
| 42 | +takesDictionaryExpressible(["one": 1]) |
| 43 | +// expected-error@-1 {{initializer 'init(dictionaryLiteral:)' is not available due to missing import of defining module 'lib'}} |
| 44 | + |
| 45 | +takesMessage("\(1)") |
| 46 | +// expected-error@-1 {{initializer 'init(stringInterpolation:)' is not available due to missing import of defining module 'lib'}} |
| 47 | +// expected-error@-2 {{instance method 'appendInterpolation' is not available due to missing import of defining module 'lib'}} |
| 48 | +// expected-error@-3 2 {{instance method 'appendLiteral' is not available due to missing import of defining module 'lib'}} |
| 49 | + |
| 50 | +takesColorExpressible(#colorLiteral(red: 0.0, green: 0.0, blue: 0.0, alpha: 1)) |
| 51 | +// FIXME: Missing diangostic |
| 52 | + |
| 53 | +takesImageExpressible(#imageLiteral(resourceName: "image.png")) |
| 54 | +// FIXME: Missing diangostic |
| 55 | + |
| 56 | +takesFileReferenceExpressible(#fileLiteral(resourceName: "file.txt")) |
| 57 | +// FIXME: Missing diangostic |
| 58 | + |
| 59 | +//--- other.swift |
| 60 | + |
| 61 | +import lib |
| 62 | + |
| 63 | +func makeSequence() -> EmptySequence { |
| 64 | + return MySequence() |
| 65 | +} |
| 66 | + |
| 67 | +func takesNilExpressible(_ x: NilExpressible) { } |
| 68 | +func takesIntExpressible(_ x: IntExpressible) { } |
| 69 | +func takesFloatExpressible(_ x: FloatExpressible) { } |
| 70 | +func takesBoolExpressible(_ x: BoolExpressible) { } |
| 71 | +func takesUnicodeScalarExpressible(_ x: UnicodeScalarExpressible) { } |
| 72 | +func takesExtendedGraphemeClusterExpressible(_ x: ExtendedGraphemeClusterExpressible) { } |
| 73 | +func takesStringLiteralExpressible(_ x: StringExpressible) { } |
| 74 | +func takesArrayExpressible<E>(_ x: ArrayExpressible<E>) { } |
| 75 | +func takesDictionaryExpressible<K, V>(_ x: DictionaryExpressible<K, V>) { } |
| 76 | +func takesMessage(_ x: Message) { } |
| 77 | +func takesColorExpressible(_ x: ColorExpressible) { } |
| 78 | +func takesImageExpressible(_ x: ImageExpressible) { } |
| 79 | +func takesFileReferenceExpressible(_ x: FileReferenceExpressible) { } |
| 80 | + |
| 81 | +//--- lib.swift |
| 82 | + |
| 83 | +public struct EmptySequence: Sequence { |
| 84 | + public struct Iterator: IteratorProtocol { |
| 85 | + public mutating func next() -> Int? { nil } |
| 86 | + } |
| 87 | + |
| 88 | + public func makeIterator() -> Iterator { Iterator() } |
| 89 | + public init() { } |
| 90 | +} |
| 91 | + |
| 92 | +public struct NilExpressible: ExpressibleByNilLiteral { |
| 93 | + public init(nilLiteral: ()) { } |
| 94 | +} |
| 95 | + |
| 96 | +public struct IntExpressible: ExpressibleByIntegerLiteral { |
| 97 | + public init(integerLiteral value: Int) { } |
| 98 | +} |
| 99 | + |
| 100 | +public struct FloatExpressible: ExpressibleByFloatLiteral { |
| 101 | + public init(floatLiteral value: Float) { } |
| 102 | +} |
| 103 | + |
| 104 | +public struct BoolExpressible: ExpressibleByBooleanLiteral { |
| 105 | + public init(booleanLiteral value: Bool) { } |
| 106 | +} |
| 107 | + |
| 108 | +public struct UnicodeScalarExpressible: ExpressibleByUnicodeScalarLiteral { |
| 109 | + public init(unicodeScalarLiteral value: Unicode.Scalar) { } |
| 110 | +} |
| 111 | + |
| 112 | +public struct ExtendedGraphemeClusterExpressible: ExpressibleByExtendedGraphemeClusterLiteral { |
| 113 | + public init(extendedGraphemeClusterLiteral value: Character) { } |
| 114 | +} |
| 115 | + |
| 116 | +public struct StringExpressible: ExpressibleByStringLiteral { |
| 117 | + public init(stringLiteral value: String) { } |
| 118 | +} |
| 119 | + |
| 120 | +public struct ArrayExpressible<Element>: ExpressibleByArrayLiteral { |
| 121 | + public init(arrayLiteral elements: Element...) { } |
| 122 | +} |
| 123 | + |
| 124 | +public struct DictionaryExpressible<Key, Value>: ExpressibleByDictionaryLiteral { |
| 125 | + public init(dictionaryLiteral elements: (Key, Value)...) { } |
| 126 | +} |
| 127 | + |
| 128 | +public struct MessageInterpolation: StringInterpolationProtocol { |
| 129 | + public init(literalCapacity: Int, interpolationCount: Int) { } |
| 130 | + public mutating func appendInterpolation(_ value: @autoclosure () -> Int) { } |
| 131 | + public mutating func appendLiteral(_ literal: String) { } |
| 132 | +} |
| 133 | + |
| 134 | +public struct Message: ExpressibleByStringInterpolation { |
| 135 | + public init(stringInterpolation: MessageInterpolation) { } |
| 136 | + public init(stringLiteral: String) { } |
| 137 | +} |
| 138 | + |
| 139 | +public struct ColorExpressible: _ExpressibleByColorLiteral { |
| 140 | + public init(_colorLiteralRed red: Float, green: Float, blue: Float, alpha: Float) { } |
| 141 | +} |
| 142 | + |
| 143 | +public struct ImageExpressible: _ExpressibleByImageLiteral { |
| 144 | + public init(imageLiteralResourceName path: String) { } |
| 145 | +} |
| 146 | + |
| 147 | +public struct FileReferenceExpressible: _ExpressibleByFileReferenceLiteral { |
| 148 | + public init(fileReferenceLiteralResourceName path: String) { } |
| 149 | +} |
0 commit comments