aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-09-18 10:57:28 -0700
committerGopher Robot <gobot@golang.org>2023-09-18 18:40:14 +0000
commit3702cb5ab95575830488dc2b1ca9424651f828cf (patch)
treeeff634cccd06a5062a33473eb71c1842353d0acc /src
parent251fb8e4112c4728bf46da15a3875c455136ed8d (diff)
downloadgo-3702cb5ab95575830488dc2b1ca9424651f828cf.tar.xz
go/types: use InvalidSyntaxTree in a couple of places (cleanup)
Change-Id: I3dcff95b49a72edc30035f50b1ac1d3f9cdec91b Reviewed-on: https://go-review.googlesource.com/c/go/+/529235 Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/go/types/expr.go2
-rw-r--r--src/go/types/interface.go6
2 files changed, 3 insertions, 5 deletions
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index 2b020a570a..b018939730 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -1334,7 +1334,7 @@ func (check *Checker) exprInternal(T Type, x *operand, e ast.Expr, hint Type) ex
}
// x.(type) expressions are handled explicitly in type switches
if e.Type == nil {
- // Don't use invalidAST because this can occur in the AST produced by
+ // Don't use InvalidSyntaxTree because this can occur in the AST produced by
// go/parser.
check.error(e, BadTypeKeyword, "use of .(type) outside type switch")
goto Error
diff --git a/src/go/types/interface.go b/src/go/types/interface.go
index ac909fa4d6..3aed723542 100644
--- a/src/go/types/interface.go
+++ b/src/go/types/interface.go
@@ -188,15 +188,13 @@ func (check *Checker) interfaceType(ityp *Interface, iface *ast.InterfaceType, d
continue // ignore
}
- // Always type-check method type parameters but complain if they are not enabled.
- // (This extra check is needed here because interface method signatures don't have
- // a receiver specification.)
+ // The go/parser doesn't accept method type parameters but an ast.FuncType may have them.
if sig.tparams != nil {
var at positioner = f.Type
if ftyp, _ := f.Type.(*ast.FuncType); ftyp != nil && ftyp.TypeParams != nil {
at = ftyp.TypeParams
}
- check.error(at, InvalidMethodTypeParams, "methods cannot have type parameters")
+ check.error(at, InvalidSyntaxTree, "methods cannot have type parameters")
}
// use named receiver type if available (for better error messages)