You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ConstraintSystem] Re-activate constraints if, due to incorrect reference, member type has been bound before base type
If member has been bound before the base and the base was
incorrect at that (e.g. fallback to default `Any` type),
then we need to re-activate all of the constraints
associated with this member reference otherwise some of
the constraints could be left unchecked in inactive state.
This is especially important for key path expressions because
`key path` constraint can't be retired until all components
are simplified.
Resolves: SR-13364
Resolves: rdar://66706980
Resolves: rdar://74711236
let _:KeyPath<String?,Int?>= \.utf8.count // expected-error {{no exact matches in reference to property 'count'}}
1059
+
// expected-note@-1 {{found candidate with type 'Int'}}
1060
+
}
1061
+
1062
+
// rdar://74711236 - crash due to incorrect member access in key path
1063
+
func rdar74711236(){
1064
+
structS{
1065
+
vararr:[V]=[]
1066
+
}
1067
+
1068
+
structV:Equatable{
1069
+
}
1070
+
1071
+
enumType{
1072
+
case store
1073
+
}
1074
+
1075
+
structContext{
1076
+
func supported()->[Type]{
1077
+
return[]
1078
+
}
1079
+
}
1080
+
1081
+
func test(context:Context?){
1082
+
vars=S()
1083
+
1084
+
s.arr ={
1085
+
// FIXME: Missing member reference is pattern needs a better diagnostic
1086
+
iflet type = context?.store { // expected-error {{type of expression is ambiguous without more context}}
1087
+
// `isSupported` should be an invalid declaration to trigger a crash in `map(\.option)`
1088
+
letisSupported= context!.supported().contains(type) // expected-error {{missing argument label 'where:' in call}} expected-error {{converting non-escaping value to '(Type) throws -> Bool' may allow it to escape}}
1089
+
return(isSupported ?[type]:[]).map(\.option)
1090
+
// expected-error@-1 {{value of type 'Any' has no member 'option'}}
1091
+
// expected-note@-2 {{cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members}}
0 commit comments