@@ -449,6 +449,16 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(
449
449
llvm::function_ref<Type(Type)> simplifyType,
450
450
llvm::function_ref<Optional<SelectedOverload>(ConstraintLocator *)>
451
451
getOverloadFor) {
452
+ if (auto conversion =
453
+ locator->findLast <LocatorPathElt::ImplicitConversion>()) {
454
+ if (conversion->is (ConversionRestrictionKind::DoubleToCGFloat) ||
455
+ conversion->is (ConversionRestrictionKind::CGFloatToDouble)) {
456
+ return getConstraintLocator (
457
+ ASTNode (), {*conversion, ConstraintLocator::ApplyFunction,
458
+ ConstraintLocator::ConstructorMember});
459
+ }
460
+ }
461
+
452
462
auto anchor = locator->getAnchor ();
453
463
assert (bool (anchor) && " Expected an anchor!" );
454
464
@@ -4304,7 +4314,10 @@ ASTNode constraints::simplifyLocatorToAnchor(ConstraintLocator *locator) {
4304
4314
}
4305
4315
4306
4316
Expr *constraints::getArgumentExpr (ASTNode node, unsigned index) {
4307
- auto *expr = castToExpr (node);
4317
+ auto *expr = getAsExpr (node);
4318
+ if (!expr)
4319
+ return nullptr ;
4320
+
4308
4321
Expr *argExpr = nullptr ;
4309
4322
if (auto *AE = dyn_cast<ApplyExpr>(expr))
4310
4323
argExpr = AE->getArg ();
@@ -4443,7 +4456,9 @@ void ConstraintSystem::generateConstraints(
4443
4456
ConstraintLocator *
4444
4457
ConstraintSystem::getArgumentInfoLocator (ConstraintLocator *locator) {
4445
4458
auto anchor = locator->getAnchor ();
4446
- if (!anchor)
4459
+
4460
+ // An empty locator which code completion uses for member references.
4461
+ if (anchor.isNull () && locator->getPath ().empty ())
4447
4462
return nullptr ;
4448
4463
4449
4464
// Applies and unresolved member exprs can have callee locators that are
@@ -4477,29 +4492,6 @@ ConstraintSystem::getArgumentInfo(ConstraintLocator *locator) {
4477
4492
if (!locator)
4478
4493
return None;
4479
4494
4480
- // Implicit conversions to/from CGFloat type are modeled without
4481
- // any changes to the AST, so we have to accomodate for that here
4482
- // by faking presence of appopriate AST location.
4483
- if (locator->isLastElement <LocatorPathElt::ApplyArgument>() ||
4484
- locator->isLastElement <LocatorPathElt::ApplyFunction>()) {
4485
- auto path = locator->getPath ().drop_back ();
4486
- if (!path.empty () && path.back ().is <LocatorPathElt::ImplicitConversion>()) {
4487
- auto conversion = path.back ()
4488
- .castTo <LocatorPathElt::ImplicitConversion>()
4489
- .getConversionKind ();
4490
-
4491
- if (conversion == ConversionRestrictionKind::DoubleToCGFloat ||
4492
- conversion == ConversionRestrictionKind::CGFloatToDouble) {
4493
- // TODO: This is not very efficient, long term we should just
4494
- // save a single `ArgumentInfo` and use it for all of
4495
- // the locations where conversion is needed.
4496
- ArrayRef<Identifier> labels{Identifier ()};
4497
- return ArgumentInfo{.Labels = allocateCopy (labels),
4498
- .UnlabeledTrailingClosureIndex = None};
4499
- }
4500
- }
4501
- }
4502
-
4503
4495
if (auto *infoLocator = getArgumentInfoLocator (locator)) {
4504
4496
auto known = ArgumentInfos.find (infoLocator);
4505
4497
if (known != ArgumentInfos.end ())
0 commit comments