Skip to content

Commit 01073be

Browse files
authored
Merge pull request #30436 from xedin/rdar-60501780
[CSBindings] Refactor a check to produce follow-up direct supertype b…
2 parents 7ac7620 + 059a360 commit 01073be

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,15 +1032,6 @@ bool TypeVarBindingProducer::computeNext() {
10321032
}
10331033
}
10341034

1035-
if (binding.Kind != BindingKind::Supertypes)
1036-
continue;
1037-
1038-
for (auto supertype : enumerateDirectSupertypes(type)) {
1039-
// If we're not allowed to try this binding, skip it.
1040-
if (auto simplifiedSuper = CS.checkTypeOfBinding(TypeVar, supertype))
1041-
addNewBinding(binding.withType(*simplifiedSuper));
1042-
}
1043-
10441035
auto srcLocator = binding.getLocator();
10451036
if (srcLocator &&
10461037
srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() &&
@@ -1059,6 +1050,14 @@ bool TypeVarBindingProducer::computeNext() {
10591050
->reconstituteSugar(/*recursive=*/false);
10601051
addNewBinding(binding.withType(newType));
10611052
}
1053+
1054+
if (binding.Kind == BindingKind::Supertypes) {
1055+
for (auto supertype : enumerateDirectSupertypes(type)) {
1056+
// If we're not allowed to try this binding, skip it.
1057+
if (auto simplifiedSuper = CS.checkTypeOfBinding(TypeVar, supertype))
1058+
addNewBinding(binding.withType(*simplifiedSuper));
1059+
}
1060+
}
10621061
}
10631062

10641063
if (newBindings.empty())

test/Constraints/bridging.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,12 @@ func bridgeTupleToAnyObject() {
374374
func rdar54274245(_ arr: [Any]?) {
375375
_ = (arr ?? []) as [NSObject]
376376
}
377+
378+
// rdar://problem/60501780 - failed to infer NSString as a value type of a dictionary
379+
func rdar60501780() {
380+
func foo(_: [String: NSObject]) {}
381+
382+
func bar(_ v: String) {
383+
foo(["": "", "": v as NSString])
384+
}
385+
}

0 commit comments

Comments
 (0)