Skip to content

Commit 842aa60

Browse files
committed
[ConstraintSystem] Teach partial application check about implicit conversions
Implicit conversion used to erase path for contextual type conversions but it does so no longer, this means that invalid partial application check needs to know about existence of implicit conversions that are not reflected in the AST until solution is applied. Resolves: rdar://99282932
1 parent e22fc3e commit 842aa60

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,13 @@ static std::pair<bool, unsigned>
27512751
isInvalidPartialApplication(ConstraintSystem &cs,
27522752
const AbstractFunctionDecl *member,
27532753
ConstraintLocator *locator) {
2754+
// If this is a compiler synthesized implicit conversion, let's skip
2755+
// the check because the base of `UDE` is not the base of the injected
2756+
// initializer.
2757+
if (locator->isLastElement<LocatorPathElt::ConstructorMember>() &&
2758+
locator->findFirst<LocatorPathElt::ImplicitConversion>())
2759+
return {false, 0};
2760+
27542761
auto *UDE = getAsExpr<UnresolvedDotExpr>(locator->getAnchor());
27552762
if (UDE == nullptr)
27562763
return {false,0};

test/Constraints/implicit_double_cgfloat_conversion.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,18 @@ do {
315315
}
316316
}
317317
}
318+
319+
// rdar://99282938
320+
func test_implicit_conversion_clash_with_partial_application_check() {
321+
class C {
322+
var duration: CGFloat { 0.3 }
323+
324+
var use: Double {
325+
duration // Ok
326+
}
327+
328+
func transitionDuration() -> TimeInterval {
329+
duration // Ok
330+
}
331+
}
332+
}

0 commit comments

Comments
 (0)