Skip to content

[NFC] VarDecls in Pattern Binding Initializers Have No Overload Type #27725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "CSDiagnostics.h"
#include "CSFix.h"
#include "TypeCheckType.h"
#include "swift/AST/Initializer.h"
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/ParameterList.h"
#include "swift/Basic/Statistic.h"
Expand Down Expand Up @@ -1460,13 +1461,20 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
if (decl->isImplicitlyUnwrappedOptional())
return Type();

// In a pattern binding initializer, all of its bound variables have no
// effective overload type.
if (auto *PBI = dyn_cast<PatternBindingInitializer>(useDC)) {
if (auto *VD = dyn_cast<VarDecl>(decl)) {
if (PBI->getBinding() == VD->getParentPatternBinding()) {
return Type();
}
}
}

// Retrieve the interface type.
auto type = decl->getInterfaceType();
if (!type) {
type = decl->getInterfaceType();
if (!type) {
return Type();
}
if (!type || type->hasError()) {
return Type();
}

// If we have a generic function type, drop the generic signature; we don't
Expand Down