]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: use InvalidSyntaxTree in a couple of places (cleanup)
authorRobert Griesemer <gri@golang.org>
Mon, 18 Sep 2023 17:57:28 +0000 (10:57 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 18 Sep 2023 18:40:14 +0000 (18:40 +0000)
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>

src/go/types/expr.go
src/go/types/interface.go

index 2b020a570a4ad3e9fe614b520b5d587f37ef245e..b0189397308822362ed224aed4b54593da4ee06a 100644 (file)
@@ -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
index ac909fa4d6139466c8d01493d0c0b92cdd517eef..3aed723542debd54fd896adcf9f0cdddd687252d 100644 (file)
@@ -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)