x/tools: improving the error message for check fact type

Fixes golang/go#50235

Change-Id: Ic9f61cb61fbf1e2cd198cc5d20bcba794c3181dc
GitHub-Last-Rev: 32d212d858102507ab6d6e510264feca9b78787e
GitHub-Pull-Request: golang/tools#356
Reviewed-on: https://go-review.googlesource.com/c/tools/+/374016
Reviewed-by: Alan Donovan <alan@alandonovan.net>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
Trust: Keith Randall <khr@golang.org>
This commit is contained in:
ye.sijun 2021-12-22 05:42:42 +00:00 committed by Tim King
parent ee1ca4ffc4
commit 72cd390b55
2 changed files with 2 additions and 2 deletions

View File

@ -890,7 +890,7 @@ func (act *action) exportPackageFact(fact analysis.Fact) {
func factType(fact analysis.Fact) reflect.Type {
t := reflect.TypeOf(fact)
if t.Kind() != reflect.Ptr {
log.Fatalf("invalid Fact type: got %T, want pointer", t)
log.Fatalf("invalid Fact type: got %T, want pointer", fact)
}
return t
}

View File

@ -390,7 +390,7 @@ func exportedFrom(obj types.Object, pkg *types.Package) bool {
func factType(fact analysis.Fact) reflect.Type {
t := reflect.TypeOf(fact)
if t.Kind() != reflect.Ptr {
panic(fmt.Sprintf("invalid Fact type: got %T, want pointer", t))
panic(fmt.Sprintf("invalid Fact type: got %T, want pointer", fact))
}
return t
}