File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
test/SourceKit/CursorInfo Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -924,6 +924,18 @@ class PrintAST : public ASTVisitor<PrintAST> {
924924 if (Options.TransformContext ) {
925925 Type CurrentType = Options.TransformContext ->getBaseType ();
926926 if (CurrentType && CurrentType->hasArchetype ()) {
927+ // OpenedArchetypeTypes get replaced by a GenericTypeParamType without a
928+ // name in mapTypeOutOfContext. The GenericTypeParamType has no children
929+ // so we can't use it for TypeTransformContext.
930+ // To work around this, replace the OpenedArchetypeType with the type of
931+ // the protocol itself.
932+ CurrentType = CurrentType.transform ([](Type T) -> Type {
933+ if (auto *Opened = T->getAs <OpenedArchetypeType>()) {
934+ return Opened->getOpenedExistentialType ();
935+ } else {
936+ return T;
937+ }
938+ });
927939 CurrentType = CurrentType->mapTypeOutOfContext ();
928940 }
929941 setCurrentType (CurrentType);
Original file line number Diff line number Diff line change 1+ protocol MyError {
2+ var myVar : String { get }
3+ }
4+
5+ func foo( error: MyError ) {
6+ _ = error. myVar
7+ }
8+
9+ // RUN: %sourcekitd-test -req=cursor -pos=6:15 %s -- %s | %FileCheck %s
10+ // CHECK: myVar
11+ // CHECK-NEXT: s:27cursor_info_existential_var7MyErrorP5myVarSSvp
12+ // CHECK-NEXT: source.lang.swift
13+ // CHECK-NEXT: String
You can’t perform that action at this time.
0 commit comments