Skip to content

Commit b30c5b8

Browse files
committed
Eliminate OpaqueTypeArchetypeType::getOrdinal(), which shouldn't be used
It only made sense on the root, and clients that care can look at the interface type.
1 parent ac4d26d commit b30c5b8

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5567,15 +5567,6 @@ class OpaqueTypeArchetypeType final : public ArchetypeType,
55675567
return T->getKind() == TypeKind::OpaqueTypeArchetype;
55685568
}
55695569

5570-
/// Get the ordinal of the type within the declaration's opaque signature.
5571-
///
5572-
/// If a method declared its return type as:
5573-
///
5574-
/// func foo() -> (some P, some Q)
5575-
///
5576-
/// then the underlying type of `some P` would be ordinal 0, and `some Q` would be ordinal 1.
5577-
unsigned getOrdinal() const;
5578-
55795570
private:
55805571
OpaqueTypeArchetypeType(GenericEnvironment *environment,
55815572
RecursiveTypeProperties properties,

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,7 @@ namespace {
37223722
StringRef label) {
37233723
printCommon(label, className);
37243724
printField("address", static_cast<void *>(T));
3725+
printRec("interface_type", T->getInterfaceType());
37253726
printFlag(T->requiresClass(), "class");
37263727
if (auto layout = T->getLayoutConstraint()) {
37273728
OS << " layout=";
@@ -3731,6 +3732,7 @@ namespace {
37313732
printField("conforms_to", proto->printRef());
37323733
if (auto superclass = T->getSuperclass())
37333734
printRec("superclass", superclass);
3735+
37343736
}
37353737

37363738
void visitPrimaryArchetypeType(PrimaryArchetypeType *T, StringRef label) {
@@ -3755,7 +3757,6 @@ namespace {
37553757
StringRef label) {
37563758
printArchetypeCommon(T, "opaque_type", label);
37573759
printField("decl", T->getDecl()->getNamingDecl()->printRef());
3758-
printField("ordinal", T->getOrdinal());
37593760
if (!T->getSubstitutions().empty()) {
37603761
OS << '\n';
37613762
SmallPtrSet<const ProtocolConformance *, 4> Dumped;

lib/AST/ASTPrinter.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,6 +5893,12 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
58935893
}
58945894

58955895
void visitOpenedArchetypeType(OpenedArchetypeType *T) {
5896+
if (auto parent = T->getParent()) {
5897+
visitParentType(parent);
5898+
printArchetypeCommon(T, getAbstractTypeParamDecl(T));
5899+
return;
5900+
}
5901+
58965902
if (Options.PrintForSIL)
58975903
Printer << "@opened(\"" << T->getOpenedExistentialID() << "\") ";
58985904
visit(T->getOpenedExistentialType());
@@ -5940,10 +5946,17 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
59405946
}
59415947

59425948
void visitOpaqueTypeArchetypeType(OpaqueTypeArchetypeType *T) {
5949+
if (auto parent = T->getParent()) {
5950+
visitParentType(parent);
5951+
printArchetypeCommon(T, getAbstractTypeParamDecl(T));
5952+
return;
5953+
}
5954+
59435955
// Try to print a named opaque type.
59445956
auto printNamedOpaque = [&] {
5945-
if (auto genericParam =
5946-
T->getDecl()->getExplicitGenericParam(T->getOrdinal())) {
5957+
unsigned ordinal =
5958+
T->getInterfaceType()->castTo<GenericTypeParamType>()->getIndex();
5959+
if (auto genericParam = T->getDecl()->getExplicitGenericParam(ordinal)) {
59475960
visit(genericParam->getDeclaredInterfaceType());
59485961
return true;
59495962
}

lib/AST/Type.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,10 +3302,6 @@ OpaqueTypeArchetypeType::OpaqueTypeArchetypeType(
33023302
{
33033303
}
33043304

3305-
unsigned OpaqueTypeArchetypeType::getOrdinal() const {
3306-
return getInterfaceType()->castTo<GenericTypeParamType>()->getIndex();
3307-
}
3308-
33093305
SequenceArchetypeType::SequenceArchetypeType(
33103306
const ASTContext &Ctx, GenericEnvironment *GenericEnv, Type InterfaceType,
33113307
ArrayRef<ProtocolDecl *> ConformsTo, Type Superclass,

0 commit comments

Comments
 (0)