mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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".
This commit is contained in:
@@ -6198,9 +6198,11 @@ public:
|
||||
if (Options.PrintTypesForDebugging || Options.PrintInSILBody)
|
||||
Printer << "@error_type ";
|
||||
visit(originalType);
|
||||
}
|
||||
else
|
||||
} else if (Options.PrintTypesForDebugging) {
|
||||
Printer << "<<error type>>";
|
||||
} else {
|
||||
Printer << "_";
|
||||
}
|
||||
}
|
||||
|
||||
void visitUnresolvedType(UnresolvedType *T,
|
||||
|
||||
@@ -54,7 +54,7 @@ final class System: DistributedActorSystem {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
// 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>>]}}
|
||||
// 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 = _]}}
|
||||
func remoteCall<Act, Err, Res>(
|
||||
on actor: Act,
|
||||
target: RemoteCallTarget,
|
||||
|
||||
@@ -213,7 +213,7 @@ func resyncParserB5() {}
|
||||
|
||||
for var i = 0; ; {
|
||||
#^TOP_LEVEL_STMT_5?check=PLAIN_TOP_LEVEL;check=TOP_LEVEL_STMT_5^#
|
||||
// TOP_LEVEL_STMT_5: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
|
||||
// TOP_LEVEL_STMT_5: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
|
||||
}
|
||||
|
||||
func resyncParserB6() {}
|
||||
@@ -234,7 +234,7 @@ func resyncParserB8() {}
|
||||
|
||||
for i in unknown_var {
|
||||
#^TOP_LEVEL_STMT_8?check=PLAIN_TOP_LEVEL;check=TOP_LEVEL_STMT_8^#
|
||||
// TOP_LEVEL_STMT_8: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
|
||||
// TOP_LEVEL_STMT_8: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
|
||||
}
|
||||
|
||||
func resyncParserB9() {}
|
||||
|
||||
@@ -129,7 +129,7 @@ func testWithNoDot() {
|
||||
|
||||
// MEMBER_NO_DOT: Begin completions, 12 items
|
||||
|
||||
// MEMBER_NO_DOT-NEXT: Decl[Subscript]/CurrNominal: [{#(index): Int#}][#<<error type>>#]; name=[:];
|
||||
// MEMBER_NO_DOT-NEXT: Decl[Subscript]/CurrNominal: [{#(index): Int#}][#_#]; name=[:];
|
||||
// MEMBER_NO_DOT-SAME: briefcomment=subscript on struct S;
|
||||
// MEMBER_NO_DOT-SAME: xmlcomment=<Other file="{{.*}}" line="44" column="3"><Name>subscript(_:)</Name><USR>s:15CompleteDocTest2S1VyXeXecip</USR><Declaration>subscript(index: Int) -> <<error type>> { 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>;
|
||||
// MEMBER_NO_DOT-SAME: rawcomment=subscript on struct S
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: %batch-code-completion
|
||||
|
||||
// GLOBAL: Decl[GlobalVar]/CurrModule: invalidDecl[#<<error type>>#];
|
||||
// GLOBAL: Decl[GlobalVar]/CurrModule: invalidDecl[#_#];
|
||||
let invalidDecl = INVALID
|
||||
|
||||
struct S {
|
||||
// MEMBER: Decl[InstanceMethod]/CurrNominal: invalidMethod()[#<<error type>>#];
|
||||
// MEMBER: Decl[InstanceMethod]/CurrNominal: invalidMethod()[#_#];
|
||||
func invalidMethod() -> INVALID
|
||||
}
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ func testSwitchCaseWhereExprIJ1(_ fooObject: FooStruct) {
|
||||
|
||||
// WITH_I_INT_LOCAL: Decl[LocalVar]/Local: i[#Int#]{{; name=.+$}}
|
||||
|
||||
// WITH_I_ERROR_LOCAL: Decl[LocalVar]/Local: i[#<<error type>>#]{{; name=.+$}}
|
||||
// WITH_I_ERROR_LOCAL: Decl[LocalVar]/Local: i[#_#]{{; name=.+$}}
|
||||
|
||||
// WITH_J_INT: Decl[LocalVar]/Local: j[#Int#]{{; name=.+$}}
|
||||
|
||||
|
||||
@@ -14,5 +14,5 @@ struct S2<T> : P1 {
|
||||
_ = S2()#^UNINFERRED^#
|
||||
|
||||
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#Int#]; name=[:]
|
||||
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#<<error type>>#]; name=[:]
|
||||
// UNINFERRED-DAG: Decl[Subscript]/Super: [{#(v0): T#}][#_#]; name=[:]
|
||||
// UNINFERRED-DAG: Keyword[self]/CurrNominal: .self[#S2<_>#]; name=self
|
||||
|
||||
@@ -14,4 +14,4 @@ func test() {
|
||||
}
|
||||
}
|
||||
|
||||
// CHECK: <Declaration>@<Type usr="s:46cursor_infer_nonmutating_from_property_wrapper5StateV">State</Type> var myState: <<error type>> { get nonmutating set }</Declaration>
|
||||
// CHECK: <Declaration>@<Type usr="s:46cursor_infer_nonmutating_from_property_wrapper5StateV">State</Type> var myState: _ { get nonmutating set }</Declaration>
|
||||
|
||||
@@ -17,11 +17,11 @@ func testInvalidStructMemberCompletion() {
|
||||
let foo: InvalidStruct
|
||||
foo.#^INVALID-MEMBER^#
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberA[#Int#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberB[#<<error type>>#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberC[#<<error type>>#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberD[#<<error type>>#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberE[#<<error type>>#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: add({#<<error type>>#})[#Void#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberB[#_#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberC[#_#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberD[#_#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceVar]/CurrNominal: memberE[#_#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: add({#_#})[#Void#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: get()[#InvalidStruct.Item#];
|
||||
// INVALID-MEMBER-DAG: Decl[InstanceMethod]/Super: set({#item: InvalidStruct.Item#})[#Void#];
|
||||
}
|
||||
@@ -45,21 +45,21 @@ func testInvalidTopLevelCompletion() {
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncBody({#param: T#})[#T#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidPartialFunc()[#Void#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncBody()[#Void#];
|
||||
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureBody[#<<error type>>#];
|
||||
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureBody[#_#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncSignature()[#Void#];
|
||||
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalMissingInit[#String#];
|
||||
// INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidGenericStruct[#InvalidGenericStruct<T, U>#];
|
||||
// INVALID-TOP-DAG: Decl[Struct]/OtherModule[errors]: InvalidStruct[#InvalidStruct#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: typeUsesFunc({#pe: InvalidEnum#}, {#pa: <<error type>>#}, {#pp: any InvalidProtocol#}, {#ps: InvalidStruct#}, {#pg: <<error type>>#}, {#pc: InvalidClass#})[#Int#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: typeUsesFunc({#pe: InvalidEnum#}, {#pa: _#}, {#pp: any InvalidProtocol#}, {#ps: InvalidStruct#}, {#pg: _#}, {#pc: InvalidClass#})[#Int#];
|
||||
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalKeypath[#InvalidStruct.Type#];
|
||||
// INVALID-TOP-DAG: Decl[TypeAlias]/OtherModule[errors]: InvalidAlias[#InvalidAlias#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncType({#param: T#})[#<<error type>>#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncType()[#<<error type>>#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidGenericFuncType({#param: T#})[#_#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncType()[#_#];
|
||||
// INVALID-TOP-DAG: Decl[GlobalVar]/OtherModule[errors]: invalidGlobalClosureType[#() -> ()#];
|
||||
// INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub1[#InvalidClassSub1#];
|
||||
// INVALID-TOP-DAG: Decl[Class]/OtherModule[errors]: InvalidClassSub2[#InvalidClassSub2#];
|
||||
// INVALID-TOP-DAG: Decl[Protocol]/OtherModule[errors]/Flair[RareType]: InvalidProtocol[#InvalidProtocol#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncThrows()[' throws'][#<<error type>>#];
|
||||
// INVALID-TOP-DAG: Decl[FreeFunction]/OtherModule[errors]: invalidFuncThrows()[' throws'][#_#];
|
||||
}
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
@@ -61,4 +61,4 @@ D().b(b: .#^B_5?check=B^#)
|
||||
// B: Begin completions, 3 items
|
||||
// B-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init({#(value): T#})[#B<T>#]; name=init(:)
|
||||
// B-DAG: Decl[StaticMethod]/CurrNominal/TypeRelation[Convertible]: void()[#B<Void>#]; name=void()
|
||||
// B-DAG: Decl[StaticMethod]/CurrNominal: data({#(data): <<error type>>#})[#<<error type>>#]; name=data(:)
|
||||
// B-DAG: Decl[StaticMethod]/CurrNominal: data({#(data): _#})[#_#]; name=data(:)
|
||||
|
||||
@@ -14,9 +14,9 @@ struct Test {
|
||||
|
||||
mutating func test<T>(v: Value<T>) {
|
||||
_ = {
|
||||
// FIXME(diagnostics): We need to figure out how to avoid mentioning <<error type>> in the second diagnostic
|
||||
// FIXME(diagnostics): This isn't a useful error message
|
||||
self.tuple = (v, 42)
|
||||
// expected-error@-1 {{generic struct 'Value' requires the types 'T' and '<<error type>>' be equivalent}}
|
||||
// expected-error@-1 {{generic struct 'Value' requires the types 'T' and '_' be equivalent}}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user