Skip to content

Commit e642a79

Browse files
author
Greg Titus
committed
Allow PlaceholderType Originator to be TypeRepr not just PlaceholderTypeRepr
1 parent 6e917b5 commit e642a79

File tree

9 files changed

+18
-19
lines changed

9 files changed

+18
-19
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7291,7 +7291,7 @@ class PlaceholderType : public TypeBase {
72917291
// recursive property logic in PlaceholderType::get.
72927292
using Originator =
72937293
llvm::PointerUnion<TypeVariableType *, DependentMemberType *, VarDecl *,
7294-
ErrorExpr *, PlaceholderTypeRepr *>;
7294+
ErrorExpr *, TypeRepr *>;
72957295

72967296
Originator O;
72977297

include/swift/Sema/ConstraintLocator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,13 @@ class LocatorPathElt::ConformanceRequirement final
985985
};
986986

987987
class LocatorPathElt::PlaceholderType final
988-
: public StoredPointerElement<PlaceholderTypeRepr> {
988+
: public StoredPointerElement<TypeRepr> {
989989
public:
990-
PlaceholderType(PlaceholderTypeRepr *placeholderRepr)
990+
PlaceholderType(TypeRepr *placeholderRepr)
991991
: StoredPointerElement(PathElementKind::PlaceholderType,
992992
placeholderRepr) {}
993993

994-
PlaceholderTypeRepr *getPlaceholderRepr() const { return getStoredPointer(); }
994+
TypeRepr *getPlaceholderRepr() const { return getStoredPointer(); }
995995

996996
static bool classof(const LocatorPathElt *elt) {
997997
return elt->getKind() == ConstraintLocator::PlaceholderType;

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3989,8 +3989,8 @@ namespace {
39893989
printFlag("error_expr");
39903990
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
39913991
printRec(DMT, "dependent_member_type");
3992-
} else if (originator.is<PlaceholderTypeRepr *>()) {
3993-
printFlag("placeholder_type_repr");
3992+
} else if (originator.is<TypeRepr *>()) {
3993+
printFlag("type_repr");
39943994
} else {
39953995
assert(false && "unknown originator");
39963996
}

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6021,8 +6021,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
60216021
Printer << "error_expr";
60226022
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
60236023
visit(DMT);
6024-
} else if (originator.is<PlaceholderTypeRepr *>()) {
6025-
Printer << "placeholder_type_repr";
6024+
} else if (originator.is<TypeRepr *>()) {
6025+
Printer << "type_repr";
60266026
} else {
60276027
assert(false && "unknown originator");
60286028
}

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9338,7 +9338,7 @@ bool InvalidMemberReferenceWithinInitAccessor::diagnoseAsError() {
93389338
}
93399339

93409340
bool ConcreteTypeSpecialization::diagnoseAsError() {
9341-
emitDiagnostic(diag::not_a_generic_type, resolveType(ConcreteType));
9341+
emitDiagnostic(diag::not_a_generic_type, ConcreteType);
93429342
return true;
93439343
}
93449344

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3116,7 +3116,7 @@ class ConcreteTypeSpecialization final : public FailureDiagnostic {
31163116
ConcreteTypeSpecialization(const Solution &solution, Type concreteTy,
31173117
ConstraintLocator *locator)
31183118
: FailureDiagnostic(solution, locator),
3119-
ConcreteType(concreteTy) {}
3119+
ConcreteType(resolveType(concreteTy)) {}
31203120

31213121
bool diagnoseAsError() override;
31223122
};

lib/Sema/CSGen.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,8 +1924,7 @@ namespace {
19241924
OpenPackElementType(CS, locator, elementEnv));
19251925
if (result->hasError()) {
19261926
auto &ctxt = CS.getASTContext();
1927-
auto *repr = new (ctxt) PlaceholderTypeRepr(specializationArg->getLoc());
1928-
result = PlaceholderType::get(ctxt, repr);
1927+
result = PlaceholderType::get(ctxt, specializationArg);
19291928
ctxt.Diags.diagnose(lAngleLoc,
19301929
diag::while_parsing_as_left_angle_bracket);
19311930
}
@@ -4806,11 +4805,11 @@ bool ConstraintSystem::generateConstraints(
48064805
// If we have a placeholder originating from a PlaceholderTypeRepr,
48074806
// tack that on to the locator.
48084807
if (auto *placeholderTy = ty->getAs<PlaceholderType>())
4809-
if (auto *placeholderRepr = placeholderTy->getOriginator()
4810-
.dyn_cast<PlaceholderTypeRepr *>())
4808+
if (auto *typeRepr = placeholderTy->getOriginator()
4809+
.dyn_cast<TypeRepr *>())
48114810
return getConstraintLocator(
48124811
convertTypeLocator,
4813-
LocatorPathElt::PlaceholderType(placeholderRepr));
4812+
LocatorPathElt::PlaceholderType(typeRepr));
48144813
return convertTypeLocator;
48154814
};
48164815

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,12 +1071,12 @@ Type ConstraintSystem::replaceInferableTypesWithTypeVars(
10711071
return openUnboundGenericType(unbound->getDecl(), unbound->getParent(),
10721072
locator, /*isTypeResolution=*/false);
10731073
} else if (auto *placeholderTy = type->getAs<PlaceholderType>()) {
1074-
if (auto *placeholderRepr = placeholderTy->getOriginator()
1075-
.dyn_cast<PlaceholderTypeRepr *>()) {
1074+
if (auto *typeRepr = placeholderTy->getOriginator()
1075+
.dyn_cast<TypeRepr *>()) {
10761076

10771077
return createTypeVariable(
10781078
getConstraintLocator(
1079-
locator, LocatorPathElt::PlaceholderType(placeholderRepr)),
1079+
locator, LocatorPathElt::PlaceholderType(typeRepr)),
10801080
TVO_CanBindToNoEscape | TVO_PrefersSubtypeBinding |
10811081
TVO_CanBindToHole);
10821082
}

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ void TypeChecker::notePlaceholderReplacementTypes(Type writtenType,
11721172
}
11731173

11741174
if (auto *origRepr =
1175-
placeholder->getOriginator().dyn_cast<PlaceholderTypeRepr *>()) {
1175+
placeholder->getOriginator().dyn_cast<TypeRepr *>()) {
11761176
t1->getASTContext()
11771177
.Diags
11781178
.diagnose(origRepr->getLoc(),

0 commit comments

Comments
 (0)