types2 handles those checks instead.
The only exception is noder.checkEmbed, since when types2
have not known about "//go:embed" pragma yet.
Updates #51691
Change-Id: I74ded03536023fe838f23fa7421e04513f904f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/394556
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
base.Errorf("invalid operation: %v (shift count type %v, must be integer)", n, r.Type())
return l, r, nil
}
- if t.IsSigned() && !types.AllowsGoVersion(curpkg(), 1, 13) {
- base.ErrorfVers("go1.13", "invalid operation: %v (signed shift count type %v)", n, r.Type())
- return l, r, nil
- }
t = l.Type()
if t != nil && t.Kind() != types.TIDEAL && !t.IsInteger() {
base.Errorf("invalid operation: %v (shift of type %v)", n, t)
// tcUnsafeAdd typechecks an OUNSAFEADD node.
func tcUnsafeAdd(n *ir.BinaryExpr) *ir.BinaryExpr {
- if !types.AllowsGoVersion(curpkg(), 1, 17) {
- base.ErrorfVers("go1.17", "unsafe.Add")
- n.SetType(nil)
- return n
- }
-
n.X = AssignConv(Expr(n.X), types.Types[types.TUNSAFEPTR], "argument to unsafe.Add")
n.Y = DefaultLit(Expr(n.Y), types.Types[types.TINT])
if n.X.Type() == nil || n.Y.Type() == nil {
// tcUnsafeSlice typechecks an OUNSAFESLICE node.
func tcUnsafeSlice(n *ir.BinaryExpr) *ir.BinaryExpr {
- if !types.AllowsGoVersion(curpkg(), 1, 17) {
- base.ErrorfVers("go1.17", "unsafe.Slice")
- n.SetType(nil)
- return n
- }
-
n.X = Expr(n.X)
n.Y = Expr(n.Y)
if n.X.Type() == nil || n.Y.Type() == nil {
// They must have same element type.
if src.IsSlice() && dst.IsPtr() && dst.Elem().IsArray() &&
types.Identical(src.Elem(), dst.Elem().Elem()) {
- if !types.AllowsGoVersion(curpkg(), 1, 17) {
- return ir.OXXX, ":\n\tconversion of slices to array pointers only supported as of -lang=go1.17"
- }
return ir.OSLICE2ARRPTR, ""
}
switch prev := seen[m.Sym]; {
case prev == nil:
seen[m.Sym] = m
- case AllowsGoVersion(t.Pkg(), 1, 14) && !explicit && Identical(m.Type, prev.Type):
+ case !explicit && Identical(m.Type, prev.Type):
return
default:
base.ErrorfAt(m.Pos, "duplicate method %s", m.Sym.Name)
}
// In 1.18, embedded types can be anything. In Go 1.17, we disallow
- // embedding anything other than interfaces.
+ // embedding anything other than interfaces. This requirement was caught
+ // by types2 already, so allow non-interface here.
if !m.Type.IsInterface() {
- if AllowsGoVersion(t.Pkg(), 1, 18) {
- continue
- }
- base.FatalfAt(m.Pos, "interface contains embedded non-interface, non-union %v", m.Type)
+ continue
}
// Embedded interface: duplicate all methods
- // (including broken ones, if any) and add to t's
- // method set.
+ // and add to t's method set.
for _, t1 := range m.Type.AllMethods().Slice() {
f := NewField(m.Pos, t1.Sym, t1.Type)
addMethod(f, false)