Skip to content

Commit bb13bd9

Browse files
committed
[TypeChecker] NFC: Test key path with contextual optional typealias type
1 parent 1516a3d commit bb13bd9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/expr/unary/keypath/keypath.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,25 @@ func test_keypath_in_any_context() {
807807
_ = foo(\String.count) // Ok
808808
}
809809

810+
protocol PWithTypeAlias {
811+
typealias Key = WritableKeyPath<Self, Int?>
812+
static var fooKey: Key? { get }
813+
static var barKey: Key! { get }
814+
static var fazKey: Key?? { get }
815+
static var bazKey: Key?! { get }
816+
}
817+
818+
func test_keypath_inference_with_optionals() {
819+
final class S : PWithTypeAlias {
820+
static var fooKey: Key? { return \.foo }
821+
static var barKey: Key! { return \.foo }
822+
static var fazKey: Key?? { return \.foo }
823+
static var bazKey: Key?! { return \.foo }
824+
825+
var foo: Int? = nil
826+
}
827+
}
828+
810829
func testSyntaxErrors() { // expected-note{{}}
811830
_ = \. ; // expected-error{{expected member name following '.'}}
812831
_ = \.a ;

0 commit comments

Comments
 (0)