Skip to content

Commit 0bfbe98

Browse files
committed
[AST] Print ErrorType as _
In preparation for removing UnresolvedType in favor of ErrorType, start printing ErrorType as `_` unless we've enabled debug printing. `<<error type>>` should never be presented to the user, instead `_` now just consistently means "unknown type".
1 parent 0a55516 commit 0bfbe98

11 files changed

+26
-24
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6198,9 +6198,11 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
61986198
if (Options.PrintTypesForDebugging || Options.PrintInSILBody)
61996199
Printer << "@error_type ";
62006200
visit(originalType);
6201-
}
6202-
else
6201+
} else if (Options.PrintTypesForDebugging) {
62036202
Printer << "<<error type>>";
6203+
} else {
6204+
Printer << "_";
6205+
}
62046206
}
62056207

62066208
void visitUnresolvedType(UnresolvedType *T,

test/Distributed/distributed_serializationRequirement_must_be_protocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class System: DistributedActorSystem {
5454
fatalError()
5555
}
5656

57-
// expected-note@+1 {{candidate has non-matching type '<Act, Err, Res> (on: Act, target: RemoteCallTarget, invocation: inout System.InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res' (aka '<Act, Err, Res> (on: Act, target: RemoteCallTarget, invocation: inout ClassInvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res') [with ResultHandler = <<error type>>]}}
57+
// expected-note@+1 {{candidate has non-matching type '<Act, Err, Res> (on: Act, target: RemoteCallTarget, invocation: inout System.InvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res' (aka '<Act, Err, Res> (on: Act, target: RemoteCallTarget, invocation: inout ClassInvocationEncoder, throwing: Err.Type, returning: Res.Type) async throws -> Res') [with ResultHandler = _]}}
5858
func remoteCall<Act, Err, Res>(
5959
on actor: Act,
6060
target: RemoteCallTarget,

test/IDE/complete_at_top_level.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func resyncParserB5() {}
213213

214214
for var i = 0; ; {
215215
#^TOP_LEVEL_STMT_5?check=PLAIN_TOP_LEVEL;check=TOP_LEVEL_STMT_5^#
216-
// TOP_LEVEL_STMT_5: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
216+
// TOP_LEVEL_STMT_5: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
217217
}
218218

219219
func resyncParserB6() {}
@@ -234,7 +234,7 @@ func resyncParserB8() {}
234234

235235
for i in unknown_var {
236236
#^TOP_LEVEL_STMT_8?check=PLAIN_TOP_LEVEL;check=TOP_LEVEL_STMT_8^#
237-
// TOP_LEVEL_STMT_8: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
237+
// TOP_LEVEL_STMT_8: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
238238
}
239239

240240
func resyncParserB9() {}

test/IDE/complete_doc_member.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func testWithNoDot() {
129129

130130
// MEMBER_NO_DOT: Begin completions, 12 items
131131

132-
// MEMBER_NO_DOT-NEXT: Decl[Subscript]/CurrNominal: [{#(index): Int#}][#<<error type>>#]; name=[:];
132+
// MEMBER_NO_DOT-NEXT: Decl[Subscript]/CurrNominal: [{#(index): Int#}][#_#]; name=[:];
133133
// MEMBER_NO_DOT-SAME: briefcomment=subscript on struct S;
134134
// MEMBER_NO_DOT-SAME: xmlcomment=<Other file="{{.*}}" line="44" column="3"><Name>subscript(_:)</Name><USR>s:15CompleteDocTest2S1VyXeXecip</USR><Declaration>subscript(index: Int) -&gt; &lt;&lt;error type&gt;&gt; { get }</Declaration><CommentParts><Abstract><Para>subscript on struct S</Para></Abstract><Parameters><Parameter><Name>index</Name><Direction isExplicit="0">in</Direction><Discussion><Para>an index into S1</Para></Discussion></Parameter></Parameters></CommentParts></Other>;
135135
// MEMBER_NO_DOT-SAME: rawcomment=subscript on struct S

test/IDE/complete_sequence_invalid.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %batch-code-completion
22

3-
// GLOBAL: Decl[GlobalVar]/CurrModule: invalidDecl[#<<error type>>#];
3+
// GLOBAL: Decl[GlobalVar]/CurrModule: invalidDecl[#_#];
44
let invalidDecl = INVALID
55

66
struct S {
7-
// MEMBER: Decl[InstanceMethod]/CurrNominal: invalidMethod()[#<<error type>>#];
7+
// MEMBER: Decl[InstanceMethod]/CurrNominal: invalidMethod()[#_#];
88
func invalidMethod() -> INVALID
99
}
1010

test/IDE/complete_stmt_controlling_expr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func testSwitchCaseWhereExprIJ1(_ fooObject: FooStruct) {
413413

414414
// WITH_I_INT_LOCAL: Decl[LocalVar]/Local: i[#Int#]{{; name=.+$}}
415415

416-
// WITH_I_ERROR_LOCAL: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
416+
// WITH_I_ERROR_LOCAL: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
417417

418418
// WITH_J_INT: Decl[LocalVar]/Local: j[#Int#]{{; name=.+$}}
419419

test/IDE/complete_uninferred_generic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct S2<T> : P1 {
1414
_ = S2()#^UNINFERRED^#
1515

1616
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#Int#]; name=[:]
17-
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#<<error type>>#]; name=[:]
17+
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#_#]; name=[:]
1818
// UNINFERRED-DAG: Keyword[self]/CurrNominal: .self[#S2<_>#]; name=self

test/SourceKit/CursorInfo/cursor_infer_nonmutating_from_property_wrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ func test() {
1414
}
1515
}
1616

17-
// CHECK: <Declaration>@<Type usr="s:46cursor_infer_nonmutating_from_property_wrapper5StateV">State</Type> var myState: &lt;&lt;error type&gt;&gt; { get nonmutating set }</Declaration>
17+
// CHECK: <Declaration>@<Type usr="s:46cursor_infer_nonmutating_from_property_wrapper5StateV">State</Type> var myState: _ { get nonmutating set }</Declaration>

test/SourceKit/Misc/load-module-with-errors.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func testInvalidStructMemberCompletion() {
1717
let foo: InvalidStruct
1818
foo.#^INVALID-MEMBER^#
1919
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberA[#Int#];
20-
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberB[#<<error type>>#];
21-
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberC[#<<error type>>#];
22-
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberD[#<<error type>>#];
23-
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberE[#<<error type>>#];
24-
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: add({#<<error type>>#})[#Void#];
20+
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberB[#_#];
21+
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberC[#_#];
22+
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberD[#_#];
23+
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberE[#_#];
24+
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: add({#_#})[#Void#];
2525
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: get()[#InvalidStruct.Item#];
2626
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: set({#item: InvalidStruct.Item#})[#Void#];
2727
}
@@ -45,21 +45,21 @@ func testInvalidTopLevelCompletion() {
4545
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncBody({#param: T#})[#T#];
4646
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidPartialFunc()[#Void#];
4747
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncBody()[#Void#];
48-
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureBody[#<<error type>>#];
48+
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureBody[#_#];
4949
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncSignature()[#Void#];
5050
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalMissingInit[#String#];
5151
// INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidGenericStruct[#InvalidGenericStruct<T, U>#];
5252
// INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidStruct[#InvalidStruct#];
53-
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: typeUsesFunc({#pe: InvalidEnum#}, {#pa: <<error type>>#}, {#pp: any InvalidProtocol#}, {#ps: InvalidStruct#}, {#pg: <<error type>>#}, {#pc: InvalidClass#})[#Int#];
53+
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: typeUsesFunc({#pe: InvalidEnum#}, {#pa: _#}, {#pp: any InvalidProtocol#}, {#ps: InvalidStruct#}, {#pg: _#}, {#pc: InvalidClass#})[#Int#];
5454
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalKeypath[#InvalidStruct.Type#];
5555
// INVALID-TOP-DAG: Decl[TypeAlias]/OtherModule[errors]: InvalidAlias[#InvalidAlias#];
56-
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncType({#param: T#})[#<<error type>>#];
57-
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncType()[#<<error type>>#];
56+
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncType({#param: T#})[#_#];
57+
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncType()[#_#];
5858
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureType[#() -> ()#];
5959
// INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub1[#InvalidClassSub1#];
6060
// INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub2[#InvalidClassSub2#];
6161
// INVALID-TOP-DAG: Decl[Protocol]/OtherModule[errors]/Flair[RareType]: InvalidProtocol[#InvalidProtocol#];
62-
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncThrows()[' throws'][#<<error type>>#];
62+
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncThrows()[' throws'][#_#];
6363
}
6464

6565
// RUN: %empty-directory(%t)

validation-test/IDE/issues_fixed/rdar63063279.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ D().b(b: .#^B_5?check=B^#)
6161
// B: Begin completions, 3 items
6262
// B-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init({#(value): T#})[#B<T>#]; name=init(:)
6363
// B-DAG: Decl[StaticMethod]/CurrNominal/TypeRelation[Convertible]: void()[#B<Void>#]; name=void()
64-
// B-DAG: Decl[StaticMethod]/CurrNominal: data({#(data): <<error type>>#})[#<<error type>>#]; name=data(:)
64+
// B-DAG: Decl[StaticMethod]/CurrNominal: data({#(data): _#})[#_#]; name=data(:)

0 commit comments

Comments
 (0)