Skip to content

Commit 0ba9baf

Browse files
committed
[ASTPrinter] Allow error type in printTransformedType
When printing an associated type that is not provided (e.g. during code-completion of overrides), we want to print the type even if there are errors. rdar://problem/30451236
1 parent e40f6c2 commit 0ba9baf

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
897897
M, cast<ValueDecl>(Current));
898898
}
899899

900-
T = T.subst(subMap, SubstFlags::DesugarMemberTypes);
900+
T = T.subst(subMap,
901+
SubstFlags::DesugarMemberTypes | SubstFlags::UseErrorType);
901902
}
902903

903904
printType(T);

test/IDE/complete_override.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOINIT_FINAL -code-completion-keywords=false | %FileCheck %s -check-prefix=PROTOINIT_FINAL
136136
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PROTOINIT_STRUCT -code-completion-keywords=false | %FileCheck %s -check-prefix=PROTOINIT_STRUCT
137137

138+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=MISSING_ASSOC_1 -code-completion-keywords=false | %FileCheck %s -check-prefix=MISSING_ASSOC_1
139+
140+
138141
@objc
139142
class TagPA {}
140143
@objc
@@ -704,3 +707,22 @@ struct RequiredS : RequiredP {
704707
// PROTOINIT_STRUCT: Begin completions, 1 items
705708
// PROTOINIT_STRUCT-DAG: init(p: Int) {|}; name=init(p: Int)
706709
// PROTOINIT_STRUCT: End completions
710+
711+
protocol AssocAndMethod {
712+
associatedtype T = Int
713+
associatedtype U: P0
714+
associatedtype V
715+
716+
func f1(_: T)
717+
func f2(_: U)
718+
func f3(_: V)
719+
}
720+
721+
struct MissingAssoc: AssocAndMethod {
722+
func #^MISSING_ASSOC_1^#
723+
}
724+
// MISSING_ASSOC_1: Begin completions
725+
// MISSING_ASSOC_1-DAG: Decl[InstanceMethod]/Super: f1(_: MissingAssoc.T) {|};
726+
// MISSING_ASSOC_1-DAG: Decl[InstanceMethod]/Super: f2(_: MissingAssoc.U) {|};
727+
// MISSING_ASSOC_1-DAG: Decl[InstanceMethod]/Super: f3(_: MissingAssoc.V) {|};
728+
// MISSING_ASSOC_1: End completions

0 commit comments

Comments
 (0)