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 @@ -581,6 +581,10 @@ static std::optional<DisjunctionInfo> preserveFavoringOfUnlabeledUnaryArgument(
581
581
if (!argumentList->isUnlabeledUnary ())
582
582
return std::nullopt;
583
583
584
+ if (!isExpr<ApplyExpr>(
585
+ cs.getParentExpr (argumentList->getUnlabeledUnaryExpr ())))
586
+ return std::nullopt;
587
+
584
588
auto ODRE = isOverloadedDeclRef (disjunction);
585
589
bool preserveFavoringOfUnlabeledUnaryArgument =
586
590
!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