Skip to content

Commit f1ae722

Browse files
xzbdmwgopherbot
authored andcommitted
gopls/internal/semtok: change types.Named to types.Basic for iota, true, and false
Fixes golang/go#70219 Change-Id: I4aacfc8f55c2b9bae17b5012cc8967329849cc6c GitHub-Last-Rev: 88ecf46 GitHub-Pull-Request: #541 Reviewed-on: https://go-review.googlesource.com/c/tools/+/625895 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent dba5486 commit f1ae722

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

gopls/internal/golang/semtok.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func (tv *tokenVisitor) ident(id *ast.Ident) {
556556
case *types.Builtin:
557557
emit(semtok.TokFunction, "defaultLibrary")
558558
case *types.Const:
559-
if is[*types.Named](obj.Type()) &&
559+
if is[*types.Basic](obj.Type()) &&
560560
(id.Name == "iota" || id.Name == "true" || id.Name == "false") {
561561
emit(semtok.TokVariable, "readonly", "defaultLibrary")
562562
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This test checks semanticTokens on builtin constants.
2+
(test for #70219.)
3+
4+
-- settings.json --
5+
{
6+
"semanticTokens": true
7+
}
8+
9+
-- flags --
10+
-ignore_extra_diags
11+
12+
-- default_lib_const.go --
13+
package p
14+
15+
func _() {
16+
a, b := false, true //@ token("false", "variable", "readonly defaultLibrary"), token("true", "variable", "readonly defaultLibrary")
17+
}
18+
19+
const (
20+
c = iota //@ token("iota", "variable", "readonly defaultLibrary")
21+
)

0 commit comments

Comments
 (0)