Skip to content

Commit f6a44cb

Browse files
author
Greg Titus
committed
Allow PlaceholderType Originator to be TypeRepr not just PlaceholderTypeRepr
1 parent fdc7e25 commit f6a44cb

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7327,7 +7327,7 @@ class PlaceholderType : public TypeBase {
73277327
// recursive property logic in PlaceholderType::get.
73287328
using Originator =
73297329
llvm::PointerUnion<TypeVariableType *, DependentMemberType *, VarDecl *,
7330-
ErrorExpr *, PlaceholderTypeRepr *>;
7330+
ErrorExpr *, TypeRepr *>;
73317331

73327332
Originator O;
73337333

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
@@ -3987,8 +3987,8 @@ namespace {
39873987
printFlag("error_expr");
39883988
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
39893989
printRec(DMT, "dependent_member_type");
3990-
} else if (originator.is<PlaceholderTypeRepr *>()) {
3991-
printFlag("placeholder_type_repr");
3990+
} else if (originator.is<TypeRepr *>()) {
3991+
printFlag("type_repr");
39923992
} else {
39933993
assert(false && "unknown originator");
39943994
}

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5870,8 +5870,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
58705870
Printer << "error_expr";
58715871
} else if (auto *DMT = originator.dyn_cast<DependentMemberType *>()) {
58725872
visit(DMT);
5873-
} else if (originator.is<PlaceholderTypeRepr *>()) {
5874-
Printer << "placeholder_type_repr";
5873+
} else if (originator.is<TypeRepr *>()) {
5874+
Printer << "type_repr";
58755875
} else {
58765876
assert(false && "unknown originator");
58775877
}

lib/Sema/CSDiagnostics.cpp

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

93629362
bool ConcreteTypeSpecialization::diagnoseAsError() {
9363-
emitDiagnostic(diag::not_a_generic_type, resolveType(ConcreteType));
9363+
emitDiagnostic(diag::not_a_generic_type, ConcreteType);
93649364
return true;
93659365
}
93669366

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3132,7 +3132,7 @@ class ConcreteTypeSpecialization final : public FailureDiagnostic {
31323132
ConcreteTypeSpecialization(const Solution &solution, Type concreteTy,
31333133
ConstraintLocator *locator)
31343134
: FailureDiagnostic(solution, locator),
3135-
ConcreteType(concreteTy) {}
3135+
ConcreteType(resolveType(concreteTy)) {}
31363136

31373137
bool diagnoseAsError() override;
31383138
};

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
}
@@ -4802,11 +4801,11 @@ bool ConstraintSystem::generateConstraints(
48024801
// If we have a placeholder originating from a PlaceholderTypeRepr,
48034802
// tack that on to the locator.
48044803
if (auto *placeholderTy = ty->getAs<PlaceholderType>())
4805-
if (auto *placeholderRepr = placeholderTy->getOriginator()
4806-
.dyn_cast<PlaceholderTypeRepr *>())
4804+
if (auto *typeRepr = placeholderTy->getOriginator()
4805+
.dyn_cast<TypeRepr *>())
48074806
return getConstraintLocator(
48084807
convertTypeLocator,
4809-
LocatorPathElt::PlaceholderType(placeholderRepr));
4808+
LocatorPathElt::PlaceholderType(typeRepr));
48104809
return convertTypeLocator;
48114810
};
48124811

lib/Sema/ConstraintSystem.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,17 +1077,17 @@ Type ConstraintSystem::replaceInferableTypesWithTypeVars(
10771077
return openUnboundGenericType(unbound->getDecl(), unbound->getParent(),
10781078
locator, /*isTypeResolution=*/false);
10791079
} else if (auto *placeholderTy = type->getAs<PlaceholderType>()) {
1080-
if (auto *placeholderRepr = placeholderTy->getOriginator()
1081-
.dyn_cast<PlaceholderTypeRepr *>()) {
1082-
1083-
return createTypeVariable(
1084-
getConstraintLocator(
1085-
locator, LocatorPathElt::PlaceholderType(placeholderRepr)),
1086-
TVO_CanBindToNoEscape | TVO_PrefersSubtypeBinding |
1087-
TVO_CanBindToHole);
1088-
}
1089-
1090-
if (auto *var = placeholderTy->getOriginator().dyn_cast<VarDecl *>()) {
1080+
if (auto *typeRepr =
1081+
placeholderTy->getOriginator().dyn_cast<TypeRepr *>()) {
1082+
if (isa<PlaceholderTypeRepr>(typeRepr)) {
1083+
return createTypeVariable(
1084+
getConstraintLocator(locator,
1085+
LocatorPathElt::PlaceholderType(typeRepr)),
1086+
TVO_CanBindToNoEscape | TVO_PrefersSubtypeBinding |
1087+
TVO_CanBindToHole);
1088+
}
1089+
} else if (auto *var =
1090+
placeholderTy->getOriginator().dyn_cast<VarDecl *>()) {
10911091
if (var->getName().hasDollarPrefix()) {
10921092
auto *repr =
10931093
new (type->getASTContext()) PlaceholderTypeRepr(var->getLoc());

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,8 @@ void TypeChecker::notePlaceholderReplacementTypes(Type writtenType,
11711171
}
11721172

11731173
if (auto *origRepr =
1174-
placeholder->getOriginator().dyn_cast<PlaceholderTypeRepr *>()) {
1174+
placeholder->getOriginator().dyn_cast<TypeRepr *>()) {
1175+
assert(isa<PlaceholderTypeRepr>(origRepr));
11751176
t1->getASTContext()
11761177
.Diags
11771178
.diagnose(origRepr->getLoc(),

0 commit comments

Comments
 (0)