File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,10 @@ static std::optional<DisjunctionInfo> preserveFavoringOfUnlabeledUnaryArgument(
580
580
if (!argumentList->isUnlabeledUnary ())
581
581
return std::nullopt;
582
582
583
+ if (!isExpr<ApplyExpr>(
584
+ cs.getParentExpr (argumentList->getUnlabeledUnaryExpr ())))
585
+ return std::nullopt;
586
+
583
587
auto ODRE = isOverloadedDeclRef (disjunction);
584
588
bool preserveFavoringOfUnlabeledUnaryArgument =
585
589
!ODRE || numOverloadChoicesMatchingOnArity (ODRE, argumentList) < 2 ;
Original file line number Diff line number Diff line change @@ -272,3 +272,21 @@ func test_variadic_static_member_is_preferred_over_partially_applied_instance_ov
272
272
let t : Test
273
273
Test . fn ( t) // Ok
274
274
}
275
+
276
+ // Unary unlabeled argument favoring hacks never applied to subscripts
277
+
278
+ protocol Subscriptable {
279
+ }
280
+
281
+ extension Subscriptable {
282
+ subscript( key: String ) -> Any ? { nil }
283
+ }
284
+
285
+ struct MyValue { }
286
+
287
+ extension Dictionary < String , MyValue > : Subscriptable { }
288
+
289
+ func test_that_unary_argument_hacks_do_not_apply_to_subscripts( dict: [ String : MyValue ] ) {
290
+ let value = dict [ " hello " ]
291
+ let _: MyValue ? = value // Ok
292
+ }
You can’t perform that action at this time.
0 commit comments