Skip to content

Commit b202766

Browse files
authored
Merge pull request #27725 from CodaFi/crop-circles
[NFC] VarDecls in Pattern Binding Initializers Have No Overload Type
2 parents dd1f030 + 84a07b9 commit b202766

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "CSDiagnostics.h"
2121
#include "CSFix.h"
2222
#include "TypeCheckType.h"
23+
#include "swift/AST/Initializer.h"
2324
#include "swift/AST/GenericEnvironment.h"
2425
#include "swift/AST/ParameterList.h"
2526
#include "swift/Basic/Statistic.h"
@@ -1460,13 +1461,20 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
14601461
if (decl->isImplicitlyUnwrappedOptional())
14611462
return Type();
14621463

1464+
// In a pattern binding initializer, all of its bound variables have no
1465+
// effective overload type.
1466+
if (auto *PBI = dyn_cast<PatternBindingInitializer>(useDC)) {
1467+
if (auto *VD = dyn_cast<VarDecl>(decl)) {
1468+
if (PBI->getBinding() == VD->getParentPatternBinding()) {
1469+
return Type();
1470+
}
1471+
}
1472+
}
1473+
14631474
// Retrieve the interface type.
14641475
auto type = decl->getInterfaceType();
1465-
if (!type) {
1466-
type = decl->getInterfaceType();
1467-
if (!type) {
1468-
return Type();
1469-
}
1476+
if (!type || type->hasError()) {
1477+
return Type();
14701478
}
14711479

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

0 commit comments

Comments
 (0)