x/tools: remove old renaming imports of go/constant as exact

Fixes golang/go#26522

Change-Id: Ie8184a358f11bc7ad855e0eeb964c29848d2263e
Reviewed-on: https://go-review.googlesource.com/128998
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Alan Donovan 2018-08-10 12:49:16 -04:00
parent 00d4fcd841
commit e96c4e2476
12 changed files with 89 additions and 90 deletions

View File

@ -7,7 +7,7 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"io" "io"
@ -213,9 +213,9 @@ func (p *printer) printDecl(keyword string, n int, printGroup func()) {
// absInt returns the absolute value of v as a *big.Int. // absInt returns the absolute value of v as a *big.Int.
// v must be a numeric value. // v must be a numeric value.
func absInt(v exact.Value) *big.Int { func absInt(v constant.Value) *big.Int {
// compute big-endian representation of v // compute big-endian representation of v
b := exact.Bytes(v) // little-endian b := constant.Bytes(v) // little-endian
for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
b[i], b[j] = b[j], b[i] b[i], b[j] = b[j], b[i]
} }
@ -229,14 +229,14 @@ var (
// floatString returns the string representation for a // floatString returns the string representation for a
// numeric value v in normalized floating-point format. // numeric value v in normalized floating-point format.
func floatString(v exact.Value) string { func floatString(v constant.Value) string {
if exact.Sign(v) == 0 { if constant.Sign(v) == 0 {
return "0.0" return "0.0"
} }
// x != 0 // x != 0
// convert |v| into a big.Rat x // convert |v| into a big.Rat x
x := new(big.Rat).SetFrac(absInt(exact.Num(v)), absInt(exact.Denom(v))) x := new(big.Rat).SetFrac(absInt(constant.Num(v)), absInt(constant.Denom(v)))
// normalize x and determine exponent e // normalize x and determine exponent e
// (This is not very efficient, but also not speed-critical.) // (This is not very efficient, but also not speed-critical.)
@ -272,7 +272,7 @@ func floatString(v exact.Value) string {
if e != 0 { if e != 0 {
s += fmt.Sprintf("e%+d", e) s += fmt.Sprintf("e%+d", e)
} }
if exact.Sign(v) < 0 { if constant.Sign(v) < 0 {
s = "-" + s s = "-" + s
} }
@ -286,29 +286,29 @@ func floatString(v exact.Value) string {
// valString returns the string representation for the value v. // valString returns the string representation for the value v.
// Setting floatFmt forces an integer value to be formatted in // Setting floatFmt forces an integer value to be formatted in
// normalized floating-point format. // normalized floating-point format.
// TODO(gri) Move this code into package exact. // TODO(gri) Move this code into package constant.
func valString(v exact.Value, floatFmt bool) string { func valString(v constant.Value, floatFmt bool) string {
switch v.Kind() { switch v.Kind() {
case exact.Int: case constant.Int:
if floatFmt { if floatFmt {
return floatString(v) return floatString(v)
} }
case exact.Float: case constant.Float:
return floatString(v) return floatString(v)
case exact.Complex: case constant.Complex:
re := exact.Real(v) re := constant.Real(v)
im := exact.Imag(v) im := constant.Imag(v)
var s string var s string
if exact.Sign(re) != 0 { if constant.Sign(re) != 0 {
s = floatString(re) s = floatString(re)
if exact.Sign(im) >= 0 { if constant.Sign(im) >= 0 {
s += " + " s += " + "
} else { } else {
s += " - " s += " - "
im = exact.UnaryOp(token.SUB, im, 0) // negate im im = constant.UnaryOp(token.SUB, im, 0) // negate im
} }
} }
// im != 0, otherwise v would be exact.Int or exact.Float // im != 0, otherwise v would be constant.Int or constant.Float
return s + floatString(im) + "i" return s + floatString(im) + "i"
} }
return v.String() return v.String()

View File

@ -8,7 +8,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"go/ast" "go/ast"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"os" "os"
@ -349,10 +349,10 @@ func describeValue(qpos *queryPos, path []ast.Node) (*describeValueResult, error
type describeValueResult struct { type describeValueResult struct {
qpos *queryPos qpos *queryPos
expr ast.Expr // query node expr ast.Expr // query node
typ types.Type // type of expression typ types.Type // type of expression
constVal exact.Value // value of expression, if constant constVal constant.Value // value of expression, if constant
obj types.Object // var/func/const object, if expr was Ident obj types.Object // var/func/const object, if expr was Ident
methods []*types.Selection methods []*types.Selection
fields []describeField fields []describeField
} }

View File

@ -64,7 +64,7 @@ import (
"fmt" "fmt"
"go/ast" "go/ast"
"go/build" "go/build"
exact "go/constant" "go/constant"
"go/format" "go/format"
"go/parser" "go/parser"
"go/token" "go/token"
@ -390,7 +390,7 @@ type Value struct {
// by Value.String. // by Value.String.
value uint64 // Will be converted to int64 when needed. value uint64 // Will be converted to int64 when needed.
signed bool // Whether the constant is a signed type. signed bool // Whether the constant is a signed type.
str string // The string representation given by the "go/exact" package. str string // The string representation given by the "go/constant" package.
} }
func (v *Value) String() string { func (v *Value) String() string {
@ -464,11 +464,11 @@ func (f *File) genDecl(node ast.Node) bool {
log.Fatalf("can't handle non-integer constant type %s", typ) log.Fatalf("can't handle non-integer constant type %s", typ)
} }
value := obj.(*types.Const).Val() // Guaranteed to succeed as this is CONST. value := obj.(*types.Const).Val() // Guaranteed to succeed as this is CONST.
if value.Kind() != exact.Int { if value.Kind() != constant.Int {
log.Fatalf("can't happen: constant is not an integer %s", name) log.Fatalf("can't happen: constant is not an integer %s", name)
} }
i64, isInt := exact.Int64Val(value) i64, isInt := constant.Int64Val(value)
u64, isUint := exact.Uint64Val(value) u64, isUint := constant.Uint64Val(value)
if !isInt && !isUint { if !isInt && !isUint {
log.Fatalf("internal error: value of %s is not an integer: %s", name, value.String()) log.Fatalf("internal error: value of %s is not an integer: %s", name, value.String())
} }

View File

@ -16,7 +16,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"go/build" "go/build"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"io" "io"
@ -777,9 +777,9 @@ func (p *parser) parseInt() string {
// number = int_lit [ "p" int_lit ] . // number = int_lit [ "p" int_lit ] .
// //
func (p *parser) parseNumber() (typ *types.Basic, val exact.Value) { func (p *parser) parseNumber() (typ *types.Basic, val constant.Value) {
// mantissa // mantissa
mant := exact.MakeFromLiteral(p.parseInt(), token.INT, 0) mant := constant.MakeFromLiteral(p.parseInt(), token.INT, 0)
if mant == nil { if mant == nil {
panic("invalid mantissa") panic("invalid mantissa")
} }
@ -792,14 +792,14 @@ func (p *parser) parseNumber() (typ *types.Basic, val exact.Value) {
p.error(err) p.error(err)
} }
if exp < 0 { if exp < 0 {
denom := exact.MakeInt64(1) denom := constant.MakeInt64(1)
denom = exact.Shift(denom, token.SHL, uint(-exp)) denom = constant.Shift(denom, token.SHL, uint(-exp))
typ = types.Typ[types.UntypedFloat] typ = types.Typ[types.UntypedFloat]
val = exact.BinaryOp(mant, token.QUO, denom) val = constant.BinaryOp(mant, token.QUO, denom)
return return
} }
if exp > 0 { if exp > 0 {
mant = exact.Shift(mant, token.SHL, uint(exp)) mant = constant.Shift(mant, token.SHL, uint(exp))
} }
typ = types.Typ[types.UntypedFloat] typ = types.Typ[types.UntypedFloat]
val = mant val = mant
@ -830,7 +830,7 @@ func (p *parser) parseConstDecl() {
p.expect('=') p.expect('=')
var typ types.Type var typ types.Type
var val exact.Value var val constant.Value
switch p.tok { switch p.tok {
case scanner.Ident: case scanner.Ident:
// bool_lit // bool_lit
@ -838,7 +838,7 @@ func (p *parser) parseConstDecl() {
p.error("expected true or false") p.error("expected true or false")
} }
typ = types.Typ[types.UntypedBool] typ = types.Typ[types.UntypedBool]
val = exact.MakeBool(p.lit == "true") val = constant.MakeBool(p.lit == "true")
p.next() p.next()
case '-', scanner.Int: case '-', scanner.Int:
@ -862,18 +862,18 @@ func (p *parser) parseConstDecl() {
p.expectKeyword("i") p.expectKeyword("i")
p.expect(')') p.expect(')')
typ = types.Typ[types.UntypedComplex] typ = types.Typ[types.UntypedComplex]
val = exact.BinaryOp(re, token.ADD, exact.MakeImag(im)) val = constant.BinaryOp(re, token.ADD, constant.MakeImag(im))
case scanner.Char: case scanner.Char:
// rune_lit // rune_lit
typ = types.Typ[types.UntypedRune] typ = types.Typ[types.UntypedRune]
val = exact.MakeFromLiteral(p.lit, token.CHAR, 0) val = constant.MakeFromLiteral(p.lit, token.CHAR, 0)
p.next() p.next()
case scanner.String: case scanner.String:
// string_lit // string_lit
typ = types.Typ[types.UntypedString] typ = types.Typ[types.UntypedString]
val = exact.MakeFromLiteral(p.lit, token.STRING, 0) val = constant.MakeFromLiteral(p.lit, token.STRING, 0)
p.next() p.next()
default: default:

View File

@ -30,7 +30,7 @@ package pointer
import ( import (
"fmt" "fmt"
exact "go/constant" "go/constant"
"go/types" "go/types"
"reflect" "reflect"
@ -1024,7 +1024,7 @@ func ext۰reflect۰ChanOf(a *analysis, cgn *cgnode) {
var dir reflect.ChanDir // unknown var dir reflect.ChanDir // unknown
if site := cgn.callersite; site != nil { if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok { if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
v, _ := exact.Int64Val(c.Value) v, _ := constant.Int64Val(c.Value)
if 0 <= v && v <= int64(reflect.BothDir) { if 0 <= v && v <= int64(reflect.BothDir) {
dir = reflect.ChanDir(v) dir = reflect.ChanDir(v)
} }
@ -1668,7 +1668,7 @@ func ext۰reflect۰rtype۰FieldByName(a *analysis, cgn *cgnode) {
var name string var name string
if site := cgn.callersite; site != nil { if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok { if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
name = exact.StringVal(c.Value) name = constant.StringVal(c.Value)
} }
} }
@ -1751,7 +1751,7 @@ func ext۰reflect۰rtype۰InOut(a *analysis, cgn *cgnode, out bool) {
index := -1 index := -1
if site := cgn.callersite; site != nil { if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok { if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
v, _ := exact.Int64Val(c.Value) v, _ := constant.Int64Val(c.Value)
index = int(v) index = int(v)
} }
} }
@ -1910,7 +1910,7 @@ func ext۰reflect۰rtype۰MethodByName(a *analysis, cgn *cgnode) {
var name string var name string
if site := cgn.callersite; site != nil { if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok { if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
name = exact.StringVal(c.Value) name = constant.StringVal(c.Value)
} }
} }

View File

@ -32,7 +32,7 @@ package ssa
import ( import (
"fmt" "fmt"
"go/ast" "go/ast"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"os" "os"
@ -63,7 +63,7 @@ var (
// SSA Value constants. // SSA Value constants.
vZero = intConst(0) vZero = intConst(0)
vOne = intConst(1) vOne = intConst(1)
vTrue = NewConst(exact.MakeBool(true), tBool) vTrue = NewConst(constant.MakeBool(true), tBool)
) )
// builder holds state associated with the package currently being built. // builder holds state associated with the package currently being built.
@ -131,11 +131,11 @@ func (b *builder) logicalBinop(fn *Function, e *ast.BinaryExpr) Value {
switch e.Op { switch e.Op {
case token.LAND: case token.LAND:
b.cond(fn, e.X, rhs, done) b.cond(fn, e.X, rhs, done)
short = NewConst(exact.MakeBool(false), t) short = NewConst(constant.MakeBool(false), t)
case token.LOR: case token.LOR:
b.cond(fn, e.X, done, rhs) b.cond(fn, e.X, done, rhs)
short = NewConst(exact.MakeBool(true), t) short = NewConst(constant.MakeBool(true), t)
} }
// Is rhs unreachable? // Is rhs unreachable?
@ -1998,7 +1998,7 @@ start:
op = token.SUB op = token.SUB
} }
loc := b.addr(fn, s.X, false) loc := b.addr(fn, s.X, false)
b.assignOp(fn, loc, NewConst(exact.MakeInt64(1), loc.typ()), op, s.Pos()) b.assignOp(fn, loc, NewConst(constant.MakeInt64(1), loc.typ()), op, s.Pos())
case *ast.AssignStmt: case *ast.AssignStmt:
switch s.Tok { switch s.Tok {

View File

@ -8,7 +8,7 @@ package ssa
import ( import (
"fmt" "fmt"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"strconv" "strconv"
@ -17,14 +17,14 @@ import (
// NewConst returns a new constant of the specified value and type. // NewConst returns a new constant of the specified value and type.
// val must be valid according to the specification of Const.Value. // val must be valid according to the specification of Const.Value.
// //
func NewConst(val exact.Value, typ types.Type) *Const { func NewConst(val constant.Value, typ types.Type) *Const {
return &Const{typ, val} return &Const{typ, val}
} }
// intConst returns an 'int' constant that evaluates to i. // intConst returns an 'int' constant that evaluates to i.
// (i is an int64 in case the host is narrower than the target.) // (i is an int64 in case the host is narrower than the target.)
func intConst(i int64) *Const { func intConst(i int64) *Const {
return NewConst(exact.MakeInt64(i), tInt) return NewConst(constant.MakeInt64(i), tInt)
} }
// nilConst returns a nil constant of the specified type, which may // nilConst returns a nil constant of the specified type, which may
@ -36,7 +36,7 @@ func nilConst(typ types.Type) *Const {
// stringConst returns a 'string' constant that evaluates to s. // stringConst returns a 'string' constant that evaluates to s.
func stringConst(s string) *Const { func stringConst(s string) *Const {
return NewConst(exact.MakeString(s), tString) return NewConst(constant.MakeString(s), tString)
} }
// zeroConst returns a new "zero" constant of the specified type, // zeroConst returns a new "zero" constant of the specified type,
@ -48,11 +48,11 @@ func zeroConst(t types.Type) *Const {
case *types.Basic: case *types.Basic:
switch { switch {
case t.Info()&types.IsBoolean != 0: case t.Info()&types.IsBoolean != 0:
return NewConst(exact.MakeBool(false), t) return NewConst(constant.MakeBool(false), t)
case t.Info()&types.IsNumeric != 0: case t.Info()&types.IsNumeric != 0:
return NewConst(exact.MakeInt64(0), t) return NewConst(constant.MakeInt64(0), t)
case t.Info()&types.IsString != 0: case t.Info()&types.IsString != 0:
return NewConst(exact.MakeString(""), t) return NewConst(constant.MakeString(""), t)
case t.Kind() == types.UnsafePointer: case t.Kind() == types.UnsafePointer:
fallthrough fallthrough
case t.Kind() == types.UntypedNil: case t.Kind() == types.UntypedNil:
@ -74,8 +74,8 @@ func (c *Const) RelString(from *types.Package) string {
var s string var s string
if c.Value == nil { if c.Value == nil {
s = "nil" s = "nil"
} else if c.Value.Kind() == exact.String { } else if c.Value.Kind() == constant.String {
s = exact.StringVal(c.Value) s = constant.StringVal(c.Value)
const max = 20 const max = 20
// TODO(adonovan): don't cut a rune in half. // TODO(adonovan): don't cut a rune in half.
if len(s) > max { if len(s) > max {
@ -121,14 +121,14 @@ func (c *Const) IsNil() bool {
// a signed 64-bit integer. // a signed 64-bit integer.
// //
func (c *Const) Int64() int64 { func (c *Const) Int64() int64 {
switch x := exact.ToInt(c.Value); x.Kind() { switch x := constant.ToInt(c.Value); x.Kind() {
case exact.Int: case constant.Int:
if i, ok := exact.Int64Val(x); ok { if i, ok := constant.Int64Val(x); ok {
return i return i
} }
return 0 return 0
case exact.Float: case constant.Float:
f, _ := exact.Float64Val(x) f, _ := constant.Float64Val(x)
return int64(f) return int64(f)
} }
panic(fmt.Sprintf("unexpected constant value: %T", c.Value)) panic(fmt.Sprintf("unexpected constant value: %T", c.Value))
@ -138,14 +138,14 @@ func (c *Const) Int64() int64 {
// an unsigned 64-bit integer. // an unsigned 64-bit integer.
// //
func (c *Const) Uint64() uint64 { func (c *Const) Uint64() uint64 {
switch x := exact.ToInt(c.Value); x.Kind() { switch x := constant.ToInt(c.Value); x.Kind() {
case exact.Int: case constant.Int:
if u, ok := exact.Uint64Val(x); ok { if u, ok := constant.Uint64Val(x); ok {
return u return u
} }
return 0 return 0
case exact.Float: case constant.Float:
f, _ := exact.Float64Val(x) f, _ := constant.Float64Val(x)
return uint64(f) return uint64(f)
} }
panic(fmt.Sprintf("unexpected constant value: %T", c.Value)) panic(fmt.Sprintf("unexpected constant value: %T", c.Value))
@ -155,7 +155,7 @@ func (c *Const) Uint64() uint64 {
// a float64. // a float64.
// //
func (c *Const) Float64() float64 { func (c *Const) Float64() float64 {
f, _ := exact.Float64Val(c.Value) f, _ := constant.Float64Val(c.Value)
return f return f
} }
@ -163,7 +163,7 @@ func (c *Const) Float64() float64 {
// fit a complex128. // fit a complex128.
// //
func (c *Const) Complex128() complex128 { func (c *Const) Complex128() complex128 {
re, _ := exact.Float64Val(exact.Real(c.Value)) re, _ := constant.Float64Val(constant.Real(c.Value))
im, _ := exact.Float64Val(exact.Imag(c.Value)) im, _ := constant.Float64Val(constant.Imag(c.Value))
return complex(re, im) return complex(re, im)
} }

View File

@ -7,7 +7,7 @@ package interp
import ( import (
"bytes" "bytes"
"fmt" "fmt"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"strings" "strings"
@ -40,7 +40,7 @@ func constValue(c *ssa.Const) value {
// TODO(adonovan): eliminate untyped constants from SSA form. // TODO(adonovan): eliminate untyped constants from SSA form.
switch t.Kind() { switch t.Kind() {
case types.Bool, types.UntypedBool: case types.Bool, types.UntypedBool:
return exact.BoolVal(c.Value) return constant.BoolVal(c.Value)
case types.Int, types.UntypedInt: case types.Int, types.UntypedInt:
// Assume sizeof(int) is same on host and target. // Assume sizeof(int) is same on host and target.
return int(c.Int64()) return int(c.Int64())
@ -75,8 +75,8 @@ func constValue(c *ssa.Const) value {
case types.Complex128, types.UntypedComplex: case types.Complex128, types.UntypedComplex:
return c.Complex128() return c.Complex128()
case types.String, types.UntypedString: case types.String, types.UntypedString:
if c.Value.Kind() == exact.String { if c.Value.Kind() == constant.String {
return exact.StringVal(c.Value) return constant.StringVal(c.Value)
} }
return string(rune(c.Int64())) return string(rune(c.Int64()))
} }

View File

@ -9,7 +9,7 @@ package ssa_test
import ( import (
"fmt" "fmt"
"go/ast" "go/ast"
exact "go/constant" "go/constant"
"go/parser" "go/parser"
"go/token" "go/token"
"go/types" "go/types"
@ -144,7 +144,7 @@ func checkConstValue(t *testing.T, prog *ssa.Program, obj *types.Const) {
return return
} }
if obj.Name() != "nil" { if obj.Name() != "nil" {
if !exact.Compare(c.Value, token.EQL, obj.Val()) { if !constant.Compare(c.Value, token.EQL, obj.Val()) {
t.Errorf("ConstValue(%s).Value (%s) != %s", t.Errorf("ConstValue(%s).Value (%s) != %s",
obj, c.Value, obj.Val()) obj, c.Value, obj.Val())
return return

View File

@ -10,7 +10,7 @@ package ssa
import ( import (
"fmt" "fmt"
"go/ast" "go/ast"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"sync" "sync"
@ -404,9 +404,8 @@ type Parameter struct {
// All source-level constant expressions are represented by a Const // All source-level constant expressions are represented by a Const
// of the same type and value. // of the same type and value.
// //
// Value holds the exact value of the constant, independent of its // Value holds the value of the constant, independent of its Type(),
// Type(), using the same representation as package go/exact uses for // using go/constant representation, or nil for a typed nil value.
// constants, or nil for a typed nil value.
// //
// Pos() returns token.NoPos. // Pos() returns token.NoPos.
// //
@ -417,7 +416,7 @@ type Parameter struct {
// //
type Const struct { type Const struct {
typ types.Type typ types.Type
Value exact.Value Value constant.Value
} }
// A Global is a named Value holding the address of a package-level // A Global is a named Value holding the address of a package-level
@ -658,7 +657,7 @@ type ChangeInterface struct {
// of X, and Program.Method(m) to find the implementation of a method. // of X, and Program.Method(m) to find the implementation of a method.
// //
// To construct the zero value of an interface type T, use: // To construct the zero value of an interface type T, use:
// NewConst(exact.MakeNil(), T, pos) // NewConst(constant.MakeNil(), T, pos)
// //
// Pos() returns the ast.CallExpr.Lparen, if the instruction arose // Pos() returns the ast.CallExpr.Lparen, if the instruction arose
// from an explicit conversion in the source. // from an explicit conversion in the source.

View File

@ -11,7 +11,7 @@ package eg_test
import ( import (
"bytes" "bytes"
"flag" "flag"
exact "go/constant" "go/constant"
"go/parser" "go/parser"
"go/token" "go/token"
"go/types" "go/types"
@ -110,7 +110,7 @@ func Test(t *testing.T) {
if err != nil { if err != nil {
if shouldFail == nil { if shouldFail == nil {
t.Errorf("NewTransformer(%s): %s", filename, err) t.Errorf("NewTransformer(%s): %s", filename, err)
} else if want := exact.StringVal(shouldFail.Val()); !strings.Contains(err.Error(), want) { } else if want := constant.StringVal(shouldFail.Val()); !strings.Contains(err.Error(), want) {
t.Errorf("NewTransformer(%s): got error %q, want error %q", filename, err, want) t.Errorf("NewTransformer(%s): got error %q, want error %q", filename, err, want)
} }
} else if shouldFail != nil { } else if shouldFail != nil {

View File

@ -7,7 +7,7 @@ package eg
import ( import (
"fmt" "fmt"
"go/ast" "go/ast"
exact "go/constant" "go/constant"
"go/token" "go/token"
"go/types" "go/types"
"log" "log"
@ -67,9 +67,9 @@ func (tr *Transformer) matchExpr(x, y ast.Expr) bool {
case *ast.BasicLit: case *ast.BasicLit:
y := y.(*ast.BasicLit) y := y.(*ast.BasicLit)
xval := exact.MakeFromLiteral(x.Value, x.Kind, 0) xval := constant.MakeFromLiteral(x.Value, x.Kind, 0)
yval := exact.MakeFromLiteral(y.Value, y.Kind, 0) yval := constant.MakeFromLiteral(y.Value, y.Kind, 0)
return exact.Compare(xval, token.EQL, yval) return constant.Compare(xval, token.EQL, yval)
case *ast.FuncLit: case *ast.FuncLit:
// func literals (and thus statement syntax) never match. // func literals (and thus statement syntax) never match.