Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7221,6 +7221,9 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
if (Options.PrintForSIL) {
auto *env = T->getGenericEnvironment();

if (!T->isRoot())
Printer << '(';

Printer << "@opened(\"" << env->getOpenedExistentialUUID() << "\", ";
auto existentialTy = env->maybeApplyOuterContextSubstitutions(
env->getOpenedExistentialType());
Expand All @@ -7232,7 +7235,8 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
auto interfaceTy = T->getInterfaceType();
auto selfTy = interfaceTy->getRootGenericParam();
auto &ctx = selfTy->getASTContext();
newAlternativeTypeNames[selfTy->getCanonicalType()] = ctx.Id_Self;
Identifier selfId = (T->isRoot() ? ctx.Id_Self : ctx.getIdentifier("Self)"));
newAlternativeTypeNames[selfTy->getCanonicalType()] = selfId;

PrintOptions::OverrideScope scope(Options);
OVERRIDE_PRINT_OPTION(scope, AlternativeTypeNames, &newAlternativeTypeNames);
Expand Down
16 changes: 16 additions & 0 deletions test/SIL/Parser/basic.sil
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,22 @@ bb0:
return %1 : $()
}

protocol P2 {
associatedtype A
}

// CHECK-LABEL: sil [ossa] @test_dependent_existential_archetype :
// CHECK: %2 = alloc_stack $(@opened("0B7C132E-8010-11F0-8526-0EA13E3AABB4", any P2) Self).A
// CHECK-LABEL: } // end sil function 'test_dependent_existential_archetype'
sil [ossa] @test_dependent_existential_archetype : $@convention(thin) (@thick any P2.Type) -> () {
bb0(%0 : $@thick any P2.Type):
%1 = open_existential_metatype %0 to $@thick (@opened("0B7C132E-8010-11F0-8526-0EA13E3AABB4", any P2) Self).Type
%2 = alloc_stack $(@opened("0B7C132E-8010-11F0-8526-0EA13E3AABB4", any P2) Self).A
dealloc_stack %2
%r = tuple ()
return %r
}

class Foo2: Foo {}

// CHECK-LABEL: sil_vtable Foo {
Expand Down
Loading