Skip to content

Commit

Permalink
go/types/internal/play: show underlying and core types
Browse files Browse the repository at this point in the history
Change-Id: I8cc27bfc08b9a81d3e3baad271b51fd95e0feae3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/527355
gopls-CI: kokoro <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Run-TryBot: Alan Donovan <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
adonovan committed Sep 11, 2023
1 parent 627959a commit 0049711
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions go/types/internal/play/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/internal/typeparams"
)

// TODO(adonovan):
Expand Down Expand Up @@ -155,10 +156,16 @@ func handleSelectJSON(w http.ResponseWriter, req *http.Request) {
modes = append(modes, mode.name)
}
}
fmt.Fprintf(out, "%T has type %v and mode %s",
fmt.Fprintf(out, "%T has type %v, mode %s",
innermostExpr, tv.Type, modes)
if tu := tv.Type.Underlying(); tu != tv.Type {
fmt.Fprintf(out, ", underlying type %v", tu)
}
if tc := typeparams.CoreType(tv.Type); tc != tv.Type {
fmt.Fprintf(out, ", core type %v", tc)
}
if tv.Value != nil {
fmt.Fprintf(out, " and constant value %v", tv.Value)
fmt.Fprintf(out, ", and constant value %v", tv.Value)
}
fmt.Fprintf(out, "\n\n")
}
Expand Down

0 comments on commit 0049711

Please sign in to comment.