File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,13 @@ class BindingSet {
391391 if (Bindings.empty ())
392392 return false ;
393393
394+ // Literal requirements always result in a subtype/supertype
395+ // relationship to a concrete type.
396+ if (llvm::any_of (Literals, [](const auto &literal) {
397+ return literal.second .viableAsBinding ();
398+ }))
399+ return false ;
400+
394401 return llvm::all_of (Bindings, [](const PotentialBinding &binding) {
395402 return binding.BindingType ->isExistentialType () &&
396403 binding.Kind == AllowedBindingKind::Subtypes;
Original file line number Diff line number Diff line change @@ -492,3 +492,30 @@ func test_arg_conformance_with_conditional_reqs(i: Int) {
492492 let _: Int ? ? = simple ( overloaded_result ( ) )
493493 let _: Int ? ? = overloaded ( overloaded_result ( ) )
494494}
495+
496+ // rdar://77570994 - regression in type unification for literal collections
497+
498+ protocol Elt {
499+ }
500+
501+ extension Int : Elt { }
502+ extension Int64 : Elt { }
503+ extension Dictionary : Elt where Key == String , Value: Elt { }
504+
505+ struct Object { }
506+
507+ extension Object : ExpressibleByDictionaryLiteral {
508+ init ( dictionaryLiteral elements: ( String , Elt ) ... ) {
509+ }
510+ }
511+
512+ enum E {
513+ case test( cond: Bool , v: Int64 )
514+
515+ var test_prop : Object {
516+ switch self {
517+ case let . test( cond, v) :
518+ return [ " obj " : [ " a " : v, " b " : cond ? 0 : 42 ] ] // Ok
519+ }
520+ }
521+ }
You can’t perform that action at this time.
0 commit comments