[CSClosure] Declarations prefixed with $ can act as inferrable placeholders

If the type for such declaration could be completely inferred it
would be used during solution application. This is used to infer
types for result builder components.
This commit is contained in:
Pavel Yaskevich
2022-05-02 11:30:06 -07:00
parent 65aeb4ad89
commit a6421fc94e
3 changed files with 63 additions and 4 deletions

View File

@@ -894,6 +894,18 @@ Type ConstraintSystem::replaceInferableTypesWithTypeVars(
TVO_CanBindToNoEscape | TVO_PrefersSubtypeBinding |
TVO_CanBindToHole);
}
if (auto *var = placeholderTy->getOriginator().dyn_cast<VarDecl *>()) {
if (var->getName().hasDollarPrefix()) {
auto *repr =
new (type->getASTContext()) PlaceholderTypeRepr(var->getLoc());
return createTypeVariable(
getConstraintLocator(locator,
LocatorPathElt::PlaceholderType(repr)),
TVO_CanBindToNoEscape | TVO_PrefersSubtypeBinding |
TVO_CanBindToHole);
}
}
}
return type;