go.tools/go/types: more implicit conversion tests
Also: Fixed grammar in selection.go comment. R=adonovan CC=golang-dev https://golang.org/cl/11962043
This commit is contained in:
parent
fb0642f5fb
commit
bb34185432
|
|
@ -76,8 +76,8 @@ func (s *Selection) Obj() Object { return s.obj }
|
||||||
func (s *Selection) Type() Type {
|
func (s *Selection) Type() Type {
|
||||||
switch s.kind {
|
switch s.kind {
|
||||||
case MethodVal:
|
case MethodVal:
|
||||||
// The type of x.f is a method with its receiver type to the
|
// The type of x.f is a method with its receiver type set
|
||||||
// type of x.
|
// to the type of x.
|
||||||
sig := *s.obj.(*Func).typ.(*Signature)
|
sig := *s.obj.(*Func).typ.(*Signature)
|
||||||
recv := *sig.recv
|
recv := *sig.recv
|
||||||
recv.typ = s.recv
|
recv.typ = s.recv
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,22 @@
|
||||||
|
|
||||||
package const1
|
package const1
|
||||||
|
|
||||||
// TODO(gri) add int/uint/uintptr sizes and tests
|
const(
|
||||||
|
mi = ^int(0)
|
||||||
|
mu = ^uint(0)
|
||||||
|
mp = ^uintptr(0)
|
||||||
|
|
||||||
|
logSizeofInt = uint(mi>>8&1 + mi>>16&1 + mi>>32&1)
|
||||||
|
logSizeofUint = uint(mu>>8&1 + mu>>16&1 + mu>>32&1)
|
||||||
|
logSizeofUintptr = uint(mp>>8&1 + mp>>16&1 + mp>>32&1)
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
minInt8 = -1<<(8<<iota - 1)
|
minInt8 = -1<<(8<<iota - 1)
|
||||||
minInt16
|
minInt16
|
||||||
minInt32
|
minInt32
|
||||||
minInt64
|
minInt64
|
||||||
|
minInt = -1<<(8<<logSizeofInt - 1)
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -20,6 +29,7 @@ const (
|
||||||
maxInt16
|
maxInt16
|
||||||
maxInt32
|
maxInt32
|
||||||
maxInt64
|
maxInt64
|
||||||
|
maxInt = 1<<(8<<logSizeofInt - 1) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -27,6 +37,8 @@ const (
|
||||||
maxUint16
|
maxUint16
|
||||||
maxUint32
|
maxUint32
|
||||||
maxUint64
|
maxUint64
|
||||||
|
maxUint = 1<<(8<<logSizeofUint) - 1
|
||||||
|
maxUintptr = 1<<(8<<logSizeofUintptr) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -76,6 +88,14 @@ var (
|
||||||
_ int64 = smallestFloat64 /* ERROR "overflows" */
|
_ int64 = smallestFloat64 /* ERROR "overflows" */
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ int = minInt /* ERROR "overflows" */ - 1
|
||||||
|
_ int = minInt
|
||||||
|
_ int = maxInt
|
||||||
|
_ int = maxInt /* ERROR "overflows" */ + 1
|
||||||
|
_ int = smallestFloat64 /* ERROR "overflows" */
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ uint8 = 0 /* ERROR "overflows" */ - 1
|
_ uint8 = 0 /* ERROR "overflows" */ - 1
|
||||||
_ uint8 = 0
|
_ uint8 = 0
|
||||||
|
|
@ -108,6 +128,22 @@ var (
|
||||||
_ uint64 = smallestFloat64 /* ERROR "overflows" */
|
_ uint64 = smallestFloat64 /* ERROR "overflows" */
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ uint = 0 /* ERROR "overflows" */ - 1
|
||||||
|
_ uint = 0
|
||||||
|
_ uint = maxUint
|
||||||
|
_ uint = maxUint /* ERROR "overflows" */ + 1
|
||||||
|
_ uint = smallestFloat64 /* ERROR "overflows" */
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ uintptr = 0 /* ERROR "overflows" */ - 1
|
||||||
|
_ uintptr = 0
|
||||||
|
_ uintptr = maxUintptr
|
||||||
|
_ uintptr = maxUintptr /* ERROR "overflows" */ + 1
|
||||||
|
_ uintptr = smallestFloat64 /* ERROR "overflows" */
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ float32 = minInt64
|
_ float32 = minInt64
|
||||||
_ float64 = minInt64
|
_ float64 = minInt64
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue