Skip to content

Commit 6b34df7

Browse files
committed
[Test] Add extensions and property wrappers to superfluously public import test
1 parent a8296e1 commit 6b34df7

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

test/Sema/superfluously-public-imports.swift

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// RUN: %target-swift-frontend -emit-module %t/ConformanceDefinition.swift -o %t -I %t
1212
// RUN: %target-swift-frontend -emit-module %t/AliasesBase.swift -o %t
1313
// RUN: %target-swift-frontend -emit-module %t/Aliases.swift -o %t -I %t
14+
// RUN: %target-swift-frontend -emit-module %t/ExtensionA.swift -o %t -I %t
15+
// RUN: %target-swift-frontend -emit-module %t/ExtensionB.swift -o %t -I %t
16+
// RUN: %target-swift-frontend -emit-module %t/PropertyWrapper.swift -o %t -I %t
1417
// RUN: %target-swift-frontend -emit-module %t/UnusedImport.swift -o %t -I %t
1518
// RUN: %target-swift-frontend -emit-module %t/UnusedPackageImport.swift -o %t -I %t
1619
// RUN: %target-swift-frontend -emit-module %t/ImportNotUseFromAPI.swift -o %t -I %t
@@ -58,6 +61,27 @@ open class Clazz {}
5861
import AliasesBase
5962
public typealias ClazzAlias = Clazz
6063

64+
//--- ExtensionA.swift
65+
import ConformanceBaseTypes
66+
extension ConformingType {
67+
public func extFuncA() {}
68+
}
69+
70+
//--- ExtensionB.swift
71+
import ConformanceBaseTypes
72+
extension ConformingType {
73+
public func extFuncB() {}
74+
}
75+
76+
//--- PropertyWrapper.swift
77+
@propertyWrapper
78+
public struct MyPropertyWrapper<T> {
79+
public var wrappedValue: T
80+
81+
public init(wrappedValue value: T) { self.wrappedValue = value }
82+
public init(_ value: T) { self.wrappedValue = value }
83+
}
84+
6185
//--- UnusedImport.swift
6286

6387
//--- UnusedPackageImport.swift
@@ -84,7 +108,11 @@ public import ConformanceBaseTypes
84108
public import ConformanceDefinition
85109
public import AliasesBase
86110
public import Aliases
111+
public import ExtensionA
112+
public import ExtensionB
113+
public import PropertyWrapper
87114

115+
/// Repeat some imports to make sure we report all of them.
88116
public import UnusedImport // expected-warning {{public import of 'UnusedImport' was not used in public declarations or inlinable code}} {{1-8=}}
89117
public import UnusedImport // expected-warning {{public import of 'UnusedImport' was not used in public declarations or inlinable code}} {{1-8=}}
90118
package import UnusedImport // expected-warning {{package import of 'UnusedImport' was not used in package declarations}} {{1-9=}}
@@ -114,7 +142,7 @@ public func useConformance(_ a: any Proto = ConformingType()) {}
114142
// expected-remark @-3 {{struct 'ConformingType' is imported via 'ConformanceBaseTypes'}}
115143
// expected-remark @-4 {{initializer 'init()' is imported via 'ConformanceBaseTypes'}}
116144

117-
@usableFromInline internal func useInDefaultValue(_ a: TypeUsedInSignature) {} // expected-remark {{struct 'TypeUsedInSignature' is imported via 'DepUsedInSignature'}}
145+
@usableFromInline internal func usableFromInlineFunc(_ a: TypeUsedInSignature) {} // expected-remark {{struct 'TypeUsedInSignature' is imported via 'DepUsedInSignature'}}
118146

119147
@inlinable
120148
public func publicFuncUsesPrivate() {
@@ -139,6 +167,16 @@ public func publicFuncUsesPrivate() {
139167
let _: ClazzAlias
140168
// expected-remark @-1 {{type alias 'ClazzAlias' is imported via 'Aliases'}}
141169
// expected-remark @-2 2 {{typealias underlying type class 'Clazz' is imported via 'AliasesBase'}}
170+
171+
let x = ConformingType()
172+
// expected-remark @-1 {{struct 'ConformingType' is imported via 'ConformanceBaseTypes'}}
173+
// expected-remark @-2 {{initializer 'init()' is imported via 'ConformanceBaseTypes'}}
174+
x.extFuncA() // expected-remark {{instance method 'extFuncA()' is imported via 'ExtensionA'}}
175+
x.extFuncB() // expected-remark {{instance method 'extFuncB()' is imported via 'ExtensionB'}}
176+
}
177+
178+
public struct StructUsingPropertyWrapper {
179+
@MyPropertyWrapper(42) public var wrapped: Any // expected-remark 2 {{generic struct 'MyPropertyWrapper' is imported via 'PropertyWrapper'}}
142180
}
143181

144182
public struct Struct { // expected-remark {{implicitly used struct 'Int' is imported via 'Swift'}}

0 commit comments

Comments
 (0)