Skip to content

Commit cfbbb28

Browse files
committed
[ConstraintSystem] Allow generic parameters to bind to holes only in diagnostic mode
If generic parameter gets opened during regular solving it cannot be bound to a hole, that can only happen in diagnostic mode, so let's not even try. Doing so also makes sure that there are no inference side-effects related to holes because bindings are ranked based on their attributes.
1 parent 4e2f3b1 commit cfbbb28

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,11 +1866,14 @@ TypeVariableType *ConstraintSystem::openGenericParameter(
18661866
auto *paramLocator = getConstraintLocator(
18671867
locator.withPathElement(LocatorPathElt::GenericParameter(parameter)));
18681868

1869-
unsigned options = (TVO_PrefersSubtypeBinding |
1870-
TVO_CanBindToHole);
1869+
unsigned options = TVO_PrefersSubtypeBinding;
1870+
18711871
if (parameter->isParameterPack())
18721872
options |= TVO_CanBindToPack;
18731873

1874+
if (shouldAttemptFixes())
1875+
options |= TVO_CanBindToHole;
1876+
18741877
auto typeVar = createTypeVariable(paramLocator, options);
18751878
auto result = replacements.insert(std::make_pair(
18761879
cast<GenericTypeParamType>(parameter->getCanonicalType()), typeVar));

0 commit comments

Comments
 (0)