mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
All but 7 tests now passing. Those 7 tests either do not refer to these circumstances or do not seem to pass even when modified to accept type specifications.
51 lines
1.5 KiB
Swift
51 lines
1.5 KiB
Swift
// RUN: %target-typecheck-verify-swift -swift-version 5 -target %target-swift-5.1-abi-triple
|
|
|
|
protocol View {
|
|
}
|
|
|
|
extension View {
|
|
func title<S>(_ title: S) -> some View where S : StringProtocol {
|
|
EmptyView()
|
|
}
|
|
|
|
func title(_ titleKey: LocalizedString) -> some View {
|
|
EmptyView()
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func background<T: ShapeStyle>(_: T) -> some View {
|
|
EmptyView()
|
|
}
|
|
}
|
|
|
|
struct EmptyView : View {}
|
|
|
|
struct Text : View {
|
|
init(_: String) {}
|
|
}
|
|
|
|
protocol ShapeStyle {
|
|
}
|
|
|
|
struct AnyShapeStyle : ShapeStyle {}
|
|
struct AnyGradient : ShapeStyle {}
|
|
|
|
struct LocalizedString : ExpressibleByStringLiteral, ExpressibleByExtendedGraphemeClusterLiteral {
|
|
init(extendedGraphemeClusterLiteral value: String) {}
|
|
init(stringLiteral: String) {}
|
|
}
|
|
|
|
func test() {
|
|
func __findValue(_: String, fallback: LocalizedString) -> LocalizedString { fatalError() }
|
|
func __findValue<T: ExpressibleByStringLiteral>(_: String, fallback: T) -> T { fatalError() }
|
|
func __findValue<T: ExpressibleByExtendedGraphemeClusterLiteral>(_: String, fallback: T) -> T { fatalError() }
|
|
|
|
func ambiguitySource() -> AnyShapeStyle { fatalError() } // expected-note {{found candidate with type '() -> AnyShapeStyle'}}
|
|
func ambiguitySource() -> AnyGradient { fatalError() } // expected-note {{found candidate with type '() -> AnyGradient'}}
|
|
|
|
Text("Test")
|
|
.title(__findValue("someKey", fallback: "<unknown>"))
|
|
.background(ambiguitySource()) // expected-error {{ambiguous use of 'ambiguitySource()'}}
|
|
}
|