@@ -783,16 +783,6 @@ namespace {
783783 DeclContext *CurDC;
784784 ConstraintSystemPhase CurrPhase;
785785
786- static const unsigned numEditorPlaceholderVariables = 2 ;
787-
788- // / A buffer of type variables used for editor placeholders. We only
789- // / use a small number of these (rotating through), to prevent expressions
790- // / with a large number of editor placeholders from flooding the constraint
791- // / system with type variables.
792- TypeVariableType *editorPlaceholderVariables[numEditorPlaceholderVariables]
793- = { nullptr , nullptr };
794- unsigned currentEditorPlaceholderVariable = 0 ;
795-
796786 // / A map from each UnresolvedMemberExpr to the respective (implicit) base
797787 // / found during our walk.
798788 llvm::MapVector<UnresolvedMemberExpr *, Type> UnresolvedBaseTypes;
@@ -3033,35 +3023,23 @@ namespace {
30333023 }
30343024
30353025 Type visitEditorPlaceholderExpr (EditorPlaceholderExpr *E) {
3026+ auto *locator = CS.getConstraintLocator (E);
3027+
30363028 if (auto *placeholderRepr = E->getPlaceholderTypeRepr ()) {
30373029 // Let's try to use specified type, if that's impossible,
30383030 // fallback to a type variable.
30393031 if (auto preferredTy = resolveTypeReferenceInExpression (
3040- placeholderRepr, TypeResolverContext::InExpression,
3041- CS.getConstraintLocator (E)))
3032+ placeholderRepr, TypeResolverContext::InExpression, locator))
30423033 return preferredTy;
30433034 }
30443035
3045- auto locator = CS.getConstraintLocator (E);
3046-
30473036 // A placeholder may have any type, but default to Void type if
30483037 // otherwise unconstrained.
3049- auto &placeholderTy
3050- = editorPlaceholderVariables[currentEditorPlaceholderVariable];
3051- if (!placeholderTy) {
3052- placeholderTy = CS.createTypeVariable (locator, TVO_CanBindToNoEscape);
3053-
3054- CS.addConstraint (ConstraintKind::Defaultable,
3055- placeholderTy,
3056- TupleType::getEmpty (CS.getASTContext ()),
3057- locator);
3058- }
3038+ auto *placeholderTy =
3039+ CS.createTypeVariable (locator, TVO_CanBindToNoEscape);
30593040
3060- // Move to the next placeholder variable.
3061- // FIXME: Cycling type variables like this is unsound.
3062- currentEditorPlaceholderVariable
3063- = (currentEditorPlaceholderVariable + 1 ) %
3064- numEditorPlaceholderVariables;
3041+ CS.addConstraint (ConstraintKind::Defaultable, placeholderTy,
3042+ TupleType::getEmpty (CS.getASTContext ()), locator);
30653043
30663044 return placeholderTy;
30673045 }
0 commit comments