mirror of
https://github.com/apple/swift.git
synced 2026-10-18 17:49:23 +02:00
The opaque values test coverage I initially added will emit to stdout, which is noisy for people's logs if the test is failing for some other reason.
38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
// RUN: %target-swift-emit-silgen-ossa -o /dev/null -enable-sil-opaque-values %s
|
|
// RUN: %target-swift-emit-silgen -verify %s
|
|
|
|
struct ImplicitMembers: Equatable {
|
|
static var implicit = ImplicitMembers()
|
|
|
|
static var optional: ImplicitMembers? = ImplicitMembers()
|
|
static func createOptional() -> ImplicitMembers? {
|
|
ImplicitMembers()
|
|
}
|
|
|
|
var another: ImplicitMembers { ImplicitMembers() }
|
|
var anotherOptional: ImplicitMembers? { ImplicitMembers() }
|
|
}
|
|
|
|
// Make sure we can SILGen these without issue.
|
|
|
|
postfix operator ^
|
|
postfix func ^ (_ lhs: ImplicitMembers) -> Int { 0 }
|
|
|
|
extension Int {
|
|
func foo() {}
|
|
var optionalMember: Int? { 0 }
|
|
}
|
|
|
|
// https://github.com/swiftlang/swift/issues/80265
|
|
// Make sure optional chaining looks through postfix operators.
|
|
var x: ImplicitMembers?
|
|
let _ = x?^.foo()
|
|
let _ = x?^.optionalMember?.foo()
|
|
let _ = x?.another^.optionalMember?.foo()
|
|
|
|
// Make sure the unresolved member chain extends up to the postfix operator,
|
|
// but the optional chain covers the entire expr.
|
|
let _ = .optional?^.foo()
|
|
let _ = .createOptional()?^.foo()
|
|
let _ = .implicit.anotherOptional?^.foo()
|