File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1591,6 +1591,10 @@ ConstraintSystem::getTypeOfMemberReference(
1591
1591
baseOpenedTy = funcTy->getResult ();
1592
1592
else
1593
1593
baseOpenedTy = refTy;
1594
+
1595
+ // It should be possible to form optional chains which start
1596
+ // from a protocol metatype.
1597
+ baseOpenedTy = baseOpenedTy->lookThroughAllOptionalTypes ();
1594
1598
}
1595
1599
} else if (baseObjTy->isExistentialType ()) {
1596
1600
auto openedArchetype = OpenedArchetypeType::get (baseObjTy);
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ struct G<T> : P {
14
14
extension P {
15
15
static var property : S { S ( ) }
16
16
17
+ static var iuoProp : S ! { S ( ) }
18
+ static var optProp : S ? { S ( ) }
19
+
17
20
static var fnProp : ( ) -> S {
18
21
{ S ( ) }
19
22
}
@@ -37,6 +40,10 @@ extension P {
37
40
38
41
_ = P . property // Ok
39
42
_ = P . property. other // Ok
43
+ _ = P . iuoProp // Ok
44
+ _ = P . iuoProp. other // Ok
45
+ _ = P . optProp // Ok
46
+ _ = P . optProp? . other // Ok
40
47
_ = P . fnProp // Ok
41
48
_ = P . fnProp ( ) // Ok
42
49
_ = P . fnProp ( ) . other // Ok
@@ -75,6 +82,14 @@ func test<T: P>(_: T) {}
75
82
76
83
test ( . property) // Ok, base is inferred as Style.Type
77
84
test ( . property. other) // Ok
85
+ test ( . iuoProp) // Ok
86
+ test ( . iuoProp. other) // Ok
87
+ test ( . optProp!) // Ok
88
+ test ( . optProp)
89
+ // expected-error@-1 {{value of optional type 'S?' must be unwrapped to a value of type 'S'}}
90
+ // expected-note@-2 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
91
+ // expected-note@-3 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
92
+ test ( . optProp!. other) // Ok
78
93
test ( . fnProp( ) ) // Ok
79
94
test ( . fnProp( ) . other) // Ok
80
95
test ( . method( ) ) // Ok, static method call on the metatype
You can’t perform that action at this time.
0 commit comments