]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types, types2: remove unnecessary pkg argument from verifyVersion
authorRobert Griesemer <gri@golang.org>
Mon, 22 May 2023 16:44:42 +0000 (09:44 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 22 May 2023 17:31:00 +0000 (17:31 +0000)
Change-Id: I802a9b8039740e71463694eb5503a81b2b75971d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496919
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 files changed:
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/resolver.go
src/cmd/compile/internal/types2/typeset.go
src/cmd/compile/internal/types2/typexpr.go
src/cmd/compile/internal/types2/version.go
src/go/types/builtins.go
src/go/types/call.go
src/go/types/decl.go
src/go/types/expr.go
src/go/types/resolver.go
src/go/types/typeset.go
src/go/types/typexpr.go
src/go/types/version.go

index 0d1b9ed5e55e43795e1acd8ec83f0c9fbf1a7d29..a65054661e129edd152b2ae59aa4e8032f3d498e 100644 (file)
@@ -227,7 +227,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _Clear:
                // clear(m)
-               check.verifyVersionf(check.pkg, call.Fun, go1_21, "clear")
+               check.verifyVersionf(call.Fun, go1_21, "clear")
 
                if !underIs(x.typ, func(u Type) bool {
                        switch u.(type) {
@@ -534,7 +534,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
        case _Max, _Min:
                // max(x, ...)
                // min(x, ...)
-               check.verifyVersionf(check.pkg, call.Fun, go1_21, bin.name)
+               check.verifyVersionf(call.Fun, go1_21, bin.name)
 
                op := token.LSS
                if id == _Max {
@@ -655,7 +655,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _Add:
                // unsafe.Add(ptr unsafe.Pointer, len IntegerType) unsafe.Pointer
-               check.verifyVersionf(check.pkg, call.Fun, go1_17, "unsafe.Add")
+               check.verifyVersionf(call.Fun, go1_17, "unsafe.Add")
 
                check.assignment(x, Typ[UnsafePointer], "argument to unsafe.Add")
                if x.mode == invalid {
@@ -787,7 +787,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _Slice:
                // unsafe.Slice(ptr *T, len IntegerType) []T
-               check.verifyVersionf(check.pkg, call.Fun, go1_17, "unsafe.Slice")
+               check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice")
 
                ptr, _ := under(x.typ).(*Pointer) // TODO(gri) should this be coreType rather than under?
                if ptr == nil {
@@ -808,7 +808,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _SliceData:
                // unsafe.SliceData(slice []T) *T
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.SliceData")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData")
 
                slice, _ := under(x.typ).(*Slice) // TODO(gri) should this be coreType rather than under?
                if slice == nil {
@@ -824,7 +824,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _String:
                // unsafe.String(ptr *byte, len IntegerType) string
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.String")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.String")
 
                check.assignment(x, NewPointer(universeByte), "argument to unsafe.String")
                if x.mode == invalid {
@@ -844,7 +844,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
        case _StringData:
                // unsafe.StringData(str string) *byte
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.StringData")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.StringData")
 
                check.assignment(x, Typ[String], "argument to unsafe.StringData")
                if x.mode == invalid {
index bc3634b6bb5b26e4bb5788cf3094d11c12b2b17c..e08e46fff44881b316fb1b1f344b53a6f732d87f 100644 (file)
@@ -42,7 +42,7 @@ func (check *Checker) funcInst(tsig *Signature, pos syntax.Pos, x *operand, inst
        } else {
                instErrPos = pos
        }
-       versionErr := !check.verifyVersionf(check.pkg, instErrPos, go1_18, "function instantiation")
+       versionErr := !check.verifyVersionf(instErrPos, go1_18, "function instantiation")
 
        // targs and xlist are the type arguments and corresponding type expressions, or nil.
        var targs []Type
@@ -311,7 +311,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                // is an error checking its arguments (for example, if an incorrect number
                // of arguments is supplied).
                if got == want && want > 0 {
-                       check.verifyVersionf(check.pkg, inst, go1_18, "function instantiation")
+                       check.verifyVersionf(inst, go1_18, "function instantiation")
                        sig = check.instantiateSignature(inst.Pos(), inst, sig, targs, xlist)
                        // targs have been consumed; proceed with checking arguments of the
                        // non-generic signature.
@@ -620,7 +620,7 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
        assert(len(tparams) == len(targs))
 
        // at the moment we only support implicit instantiations of argument functions
-       _ = len(genericArgs) > 0 && check.verifyVersionf(check.pkg, args[genericArgs[0]], go1_21, "implicitly instantiated function as argument")
+       _ = len(genericArgs) > 0 && check.verifyVersionf(args[genericArgs[0]], go1_21, "implicitly instantiated function as argument")
 
        // tparams holds the type parameters of the callee and generic function arguments, if any:
        // the first n type parameters belong to the callee, followed by mi type parameters for each
index 193308f197cbce2b5c03b02a16f827f4f16c5106..88864cb93e83b08d9583acee6ddcea48588ddf31 100644 (file)
@@ -492,7 +492,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
                        check.validType(t)
                }
                // If typ is local, an error was already reported where typ is specified/defined.
-               _ = check.isImportedConstraint(rhs) && check.verifyVersionf(check.pkg, tdecl.Type, go1_18, "using type constraint %s", rhs)
+               _ = check.isImportedConstraint(rhs) && check.verifyVersionf(tdecl.Type, go1_18, "using type constraint %s", rhs)
        }).describef(obj, "validType(%s)", obj.Name())
 
        alias := tdecl.Alias
@@ -505,7 +505,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
 
        // alias declaration
        if alias {
-               check.verifyVersionf(check.pkg, tdecl, go1_9, "type aliases")
+               check.verifyVersionf(tdecl, go1_9, "type aliases")
                check.brokenAlias(obj)
                rhs = check.typ(tdecl.Type)
                check.validAlias(obj, rhs)
index 6904de1a0bfc092a17401337aa4b6ae2305d59a3..67afbfb0585de192517b8a8b3d97b42bd3d3c1d8 100644 (file)
@@ -679,7 +679,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
                // Check that RHS is otherwise at least of integer type.
                switch {
                case allInteger(y.typ):
-                       if !allUnsigned(y.typ) && !check.verifyVersionf(check.pkg, y, go1_13, invalidOp+"signed shift count %s", y) {
+                       if !allUnsigned(y.typ) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
                                x.mode = invalid
                                return
                        }
index e1fe5aa9b7c41143f079e96131d4700a2f7cef42..956f8d503cc0abb116770fce17e1e9c1646e958a 100644 (file)
@@ -223,7 +223,7 @@ func (check *Checker) collectObjects() {
                // but there is no corresponding package object.
                check.recordDef(file.PkgName, nil)
 
-               fileScope := NewScope(check.pkg.scope, syntax.StartPos(file), syntax.EndPos(file), check.filename(fileNo))
+               fileScope := NewScope(pkg.scope, syntax.StartPos(file), syntax.EndPos(file), check.filename(fileNo))
                fileScopes = append(fileScopes, fileScope)
                check.recordScope(file, fileScope)
 
@@ -406,7 +406,7 @@ func (check *Checker) collectObjects() {
                                }
 
                        case *syntax.TypeDecl:
-                               _ = len(s.TParamList) != 0 && check.verifyVersionf(pkg, s.TParamList[0], go1_18, "type parameter")
+                               _ = len(s.TParamList) != 0 && check.verifyVersionf(s.TParamList[0], go1_18, "type parameter")
                                obj := NewTypeName(s.Name.Pos(), pkg, s.Name.Value, nil)
                                check.declarePkgObj(s.Name, obj, &declInfo{file: fileScope, tdecl: s})
 
@@ -453,7 +453,7 @@ func (check *Checker) collectObjects() {
                                        }
                                        check.recordDef(s.Name, obj)
                                }
-                               _ = len(s.TParamList) != 0 && !hasTParamError && check.verifyVersionf(pkg, s.TParamList[0], go1_18, "type parameter")
+                               _ = len(s.TParamList) != 0 && !hasTParamError && check.verifyVersionf(s.TParamList[0], go1_18, "type parameter")
                                info := &declInfo{file: fileScope, fdecl: s}
                                // Methods are not package-level objects but we still track them in the
                                // object map so that we can handle them like regular functions (if the
index fe1d8773cda2d44a6a3dbb7f5fb23b3742d47303..9c1c69c40b4471b78fed92c6f67e9bb924423171 100644 (file)
@@ -278,7 +278,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_
                        assert(!isTypeParam(typ))
                        tset := computeInterfaceTypeSet(check, pos, u)
                        // If typ is local, an error was already reported where typ is specified/defined.
-                       if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(check.pkg, pos, go1_18, "embedding constraint interface %s", typ) {
+                       if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(pos, go1_18, "embedding constraint interface %s", typ) {
                                continue
                        }
                        comparable = tset.comparable
@@ -287,7 +287,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_
                        }
                        terms = tset.terms
                case *Union:
-                       if check != nil && !check.verifyVersionf(check.pkg, pos, go1_18, "embedding interface element %s", u) {
+                       if check != nil && !check.verifyVersionf(pos, go1_18, "embedding interface element %s", u) {
                                continue
                        }
                        tset := computeUnionTypeSet(check, unionSets, pos, u)
@@ -301,7 +301,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_
                        if u == Typ[Invalid] {
                                continue
                        }
-                       if check != nil && !check.verifyVersionf(check.pkg, pos, go1_18, "embedding non-interface type %s", typ) {
+                       if check != nil && !check.verifyVersionf(pos, go1_18, "embedding non-interface type %s", typ) {
                                continue
                        }
                        terms = termlist{{false, typ}}
index 1670b12a96aa3f5676fea7d1096979906382f964..ca717fed8bdf219e8571de912c8dad4977f6a6a1 100644 (file)
@@ -42,7 +42,7 @@ func (check *Checker) ident(x *operand, e *syntax.Name, def *Named, wantType boo
                }
                return
        case universeAny, universeComparable:
-               if !check.verifyVersionf(check.pkg, e, go1_18, "predeclared %s", e.Value) {
+               if !check.verifyVersionf(e, go1_18, "predeclared %s", e.Value) {
                        return // avoid follow-on errors
                }
        }
@@ -271,7 +271,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) {
                }
 
        case *syntax.IndexExpr:
-               check.verifyVersionf(check.pkg, e, go1_18, "type instantiation")
+               check.verifyVersionf(e, go1_18, "type instantiation")
                return check.instantiatedType(e.X, unpackExpr(e.Index), def)
 
        case *syntax.ParenExpr:
index 3b655aad38ac64e53cf45049a32605d79fd036bd..7d01b829a95e05342fb6fdf4c784f4b74a153681 100644 (file)
@@ -141,9 +141,10 @@ func (check *Checker) allowVersion(pkg *Package, at poser, v version) bool {
 }
 
 // verifyVersionf is like allowVersion but also accepts a format string and arguments
-// which are used to report a version error if allowVersion returns false.
-func (check *Checker) verifyVersionf(pkg *Package, at poser, v version, format string, args ...interface{}) bool {
-       if !check.allowVersion(pkg, at, v) {
+// which are used to report a version error if allowVersion returns false. It uses the
+// current package.
+func (check *Checker) verifyVersionf(at poser, v version, format string, args ...interface{}) bool {
+       if !check.allowVersion(check.pkg, at, v) {
                check.versionErrorf(at, v, format, args...)
                return false
        }
index 85449338407cf469f658e0159b271903a5d9301c..fcbb71249463cb30edda3513b55ec850727098ba 100644 (file)
@@ -226,7 +226,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _Clear:
                // clear(m)
-               check.verifyVersionf(check.pkg, call.Fun, go1_21, "clear")
+               check.verifyVersionf(call.Fun, go1_21, "clear")
 
                if !underIs(x.typ, func(u Type) bool {
                        switch u.(type) {
@@ -533,7 +533,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
        case _Max, _Min:
                // max(x, ...)
                // min(x, ...)
-               check.verifyVersionf(check.pkg, call.Fun, go1_21, bin.name)
+               check.verifyVersionf(call.Fun, go1_21, bin.name)
 
                op := token.LSS
                if id == _Max {
@@ -654,7 +654,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _Add:
                // unsafe.Add(ptr unsafe.Pointer, len IntegerType) unsafe.Pointer
-               check.verifyVersionf(check.pkg, call.Fun, go1_17, "unsafe.Add")
+               check.verifyVersionf(call.Fun, go1_17, "unsafe.Add")
 
                check.assignment(x, Typ[UnsafePointer], "argument to unsafe.Add")
                if x.mode == invalid {
@@ -786,7 +786,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _Slice:
                // unsafe.Slice(ptr *T, len IntegerType) []T
-               check.verifyVersionf(check.pkg, call.Fun, go1_17, "unsafe.Slice")
+               check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice")
 
                ptr, _ := under(x.typ).(*Pointer) // TODO(gri) should this be coreType rather than under?
                if ptr == nil {
@@ -807,7 +807,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _SliceData:
                // unsafe.SliceData(slice []T) *T
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.SliceData")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData")
 
                slice, _ := under(x.typ).(*Slice) // TODO(gri) should this be coreType rather than under?
                if slice == nil {
@@ -823,7 +823,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _String:
                // unsafe.String(ptr *byte, len IntegerType) string
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.String")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.String")
 
                check.assignment(x, NewPointer(universeByte), "argument to unsafe.String")
                if x.mode == invalid {
@@ -843,7 +843,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
        case _StringData:
                // unsafe.StringData(str string) *byte
-               check.verifyVersionf(check.pkg, call.Fun, go1_20, "unsafe.StringData")
+               check.verifyVersionf(call.Fun, go1_20, "unsafe.StringData")
 
                check.assignment(x, Typ[String], "argument to unsafe.StringData")
                if x.mode == invalid {
index df48bf19e4faec8eadfc6ec9e1cc260862ece346..9016f6fd5085b828a87e7bcf1e0ec2d81e0af7a7 100644 (file)
@@ -44,7 +44,7 @@ func (check *Checker) funcInst(tsig *Signature, pos token.Pos, x *operand, ix *t
        } else {
                instErrPos = atPos(pos)
        }
-       versionErr := !check.verifyVersionf(check.pkg, instErrPos, go1_18, "function instantiation")
+       versionErr := !check.verifyVersionf(instErrPos, go1_18, "function instantiation")
 
        // targs and xlist are the type arguments and corresponding type expressions, or nil.
        var targs []Type
@@ -316,7 +316,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                // is an error checking its arguments (for example, if an incorrect number
                // of arguments is supplied).
                if got == want && want > 0 {
-                       check.verifyVersionf(check.pkg, atPos(ix.Lbrack), go1_18, "function instantiation")
+                       check.verifyVersionf(atPos(ix.Lbrack), go1_18, "function instantiation")
                        sig = check.instantiateSignature(ix.Pos(), ix.Orig, sig, targs, xlist)
                        // targs have been consumed; proceed with checking arguments of the
                        // non-generic signature.
@@ -623,7 +623,7 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type
        assert(len(tparams) == len(targs))
 
        // at the moment we only support implicit instantiations of argument functions
-       _ = len(genericArgs) > 0 && check.verifyVersionf(check.pkg, args[genericArgs[0]], go1_21, "implicitly instantiated function as argument")
+       _ = len(genericArgs) > 0 && check.verifyVersionf(args[genericArgs[0]], go1_21, "implicitly instantiated function as argument")
 
        // tparams holds the type parameters of the callee and generic function arguments, if any:
        // the first n type parameters belong to the callee, followed by mi type parameters for each
index 4b7fb331c6208a59338a7d4229a35f9c933fc291..af8ec8435e85f22c5c1829b44380c5888e759aa7 100644 (file)
@@ -561,7 +561,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {
                        check.validType(t)
                }
                // If typ is local, an error was already reported where typ is specified/defined.
-               _ = check.isImportedConstraint(rhs) && check.verifyVersionf(check.pkg, tdecl.Type, go1_18, "using type constraint %s", rhs)
+               _ = check.isImportedConstraint(rhs) && check.verifyVersionf(tdecl.Type, go1_18, "using type constraint %s", rhs)
        }).describef(obj, "validType(%s)", obj.Name())
 
        alias := tdecl.Assign.IsValid()
@@ -574,7 +574,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {
 
        // alias declaration
        if alias {
-               check.verifyVersionf(check.pkg, atPos(tdecl.Assign), go1_9, "type aliases")
+               check.verifyVersionf(atPos(tdecl.Assign), go1_9, "type aliases")
                check.brokenAlias(obj)
                rhs = check.typ(tdecl.Type)
                check.validAlias(obj, rhs)
index 69cf008b99af212449c3ef610a5967f61d6b37f9..fd776c23502f2ff05b78540b81f379591ef98443 100644 (file)
@@ -657,7 +657,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
                // Check that RHS is otherwise at least of integer type.
                switch {
                case allInteger(y.typ):
-                       if !allUnsigned(y.typ) && !check.verifyVersionf(check.pkg, y, go1_13, invalidOp+"signed shift count %s", y) {
+                       if !allUnsigned(y.typ) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
                                x.mode = invalid
                                return
                        }
index 6e175a7615c243c7ba25be5fb83830b310ab702f..6f927446e296d45d257687f3235f07c9e8210c2b 100644 (file)
@@ -242,7 +242,7 @@ func (check *Checker) collectObjects() {
                if f := check.fset.File(file.Pos()); f != nil {
                        pos, end = token.Pos(f.Base()), token.Pos(f.Base()+f.Size())
                }
-               fileScope := NewScope(check.pkg.scope, pos, end, check.filename(fileNo))
+               fileScope := NewScope(pkg.scope, pos, end, check.filename(fileNo))
                fileScopes = append(fileScopes, fileScope)
                check.recordScope(file, fileScope)
 
@@ -386,7 +386,7 @@ func (check *Checker) collectObjects() {
                                        check.declarePkgObj(name, obj, di)
                                }
                        case typeDecl:
-                               _ = d.spec.TypeParams.NumFields() != 0 && check.verifyVersionf(pkg, d.spec.TypeParams.List[0], go1_18, "type parameter")
+                               _ = d.spec.TypeParams.NumFields() != 0 && check.verifyVersionf(d.spec.TypeParams.List[0], go1_18, "type parameter")
                                obj := NewTypeName(d.spec.Name.Pos(), pkg, d.spec.Name.Name, nil)
                                check.declarePkgObj(d.spec.Name, obj, &declInfo{file: fileScope, tdecl: d.spec})
                        case funcDecl:
@@ -442,7 +442,7 @@ func (check *Checker) collectObjects() {
                                        }
                                        check.recordDef(d.decl.Name, obj)
                                }
-                               _ = d.decl.Type.TypeParams.NumFields() != 0 && !hasTParamError && check.verifyVersionf(pkg, d.decl.Type.TypeParams.List[0], go1_18, "type parameter")
+                               _ = d.decl.Type.TypeParams.NumFields() != 0 && !hasTParamError && check.verifyVersionf(d.decl.Type.TypeParams.List[0], go1_18, "type parameter")
                                info := &declInfo{file: fileScope, fdecl: d.decl}
                                // Methods are not package-level objects but we still track them in the
                                // object map so that we can handle them like regular functions (if the
index 9489f6ae87b7b3f5f88c689c6f3ace1c8b289c02..2644fa395163f1647317ca364cd57628ab17506d 100644 (file)
@@ -276,7 +276,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
                        assert(!isTypeParam(typ))
                        tset := computeInterfaceTypeSet(check, pos, u)
                        // If typ is local, an error was already reported where typ is specified/defined.
-                       if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(check.pkg, atPos(pos), go1_18, "embedding constraint interface %s", typ) {
+                       if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(atPos(pos), go1_18, "embedding constraint interface %s", typ) {
                                continue
                        }
                        comparable = tset.comparable
@@ -285,7 +285,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
                        }
                        terms = tset.terms
                case *Union:
-                       if check != nil && !check.verifyVersionf(check.pkg, atPos(pos), go1_18, "embedding interface element %s", u) {
+                       if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding interface element %s", u) {
                                continue
                        }
                        tset := computeUnionTypeSet(check, unionSets, pos, u)
@@ -299,7 +299,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T
                        if u == Typ[Invalid] {
                                continue
                        }
-                       if check != nil && !check.verifyVersionf(check.pkg, atPos(pos), go1_18, "embedding non-interface type %s", typ) {
+                       if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding non-interface type %s", typ) {
                                continue
                        }
                        terms = termlist{{false, typ}}
index 8347e8ec76b3d9bb2e93aa52333d82dccb1b9352..ca390ab9223ba23326feb7e202e4c3f3a9279d62 100644 (file)
@@ -43,7 +43,7 @@ func (check *Checker) ident(x *operand, e *ast.Ident, def *Named, wantType bool)
                }
                return
        case universeAny, universeComparable:
-               if !check.verifyVersionf(check.pkg, e, go1_18, "predeclared %s", e.Name) {
+               if !check.verifyVersionf(e, go1_18, "predeclared %s", e.Name) {
                        return // avoid follow-on errors
                }
        }
@@ -272,7 +272,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) {
 
        case *ast.IndexExpr, *ast.IndexListExpr:
                ix := typeparams.UnpackIndexExpr(e)
-               check.verifyVersionf(check.pkg, inNode(e, ix.Lbrack), go1_18, "type instantiation")
+               check.verifyVersionf(inNode(e, ix.Lbrack), go1_18, "type instantiation")
                return check.instantiatedType(ix, def)
 
        case *ast.ParenExpr:
index 8962e2f06cbffa1aaa5e608ea168a8594363dd58..07a42a79eed24bdd257c005776fa597b6af856d7 100644 (file)
@@ -142,9 +142,10 @@ func (check *Checker) allowVersion(pkg *Package, at positioner, v version) bool
 }
 
 // verifyVersionf is like allowVersion but also accepts a format string and arguments
-// which are used to report a version error if allowVersion returns false.
-func (check *Checker) verifyVersionf(pkg *Package, at positioner, v version, format string, args ...interface{}) bool {
-       if !check.allowVersion(pkg, at, v) {
+// which are used to report a version error if allowVersion returns false. It uses the
+// current package.
+func (check *Checker) verifyVersionf(at positioner, v version, format string, args ...interface{}) bool {
+       if !check.allowVersion(check.pkg, at, v) {
                check.versionErrorf(at, v, format, args...)
                return false
        }