diff --git a/src/go/types/testdata/typeparams.go2 b/src/go/types/testdata/typeparams.go2 index b069b24f62..98c5c18927 100644 --- a/src/go/types/testdata/typeparams.go2 +++ b/src/go/types/testdata/typeparams.go2 @@ -37,15 +37,25 @@ func swapswap(type A, B)(a A, b B) (A, B) { return swap(B, A)(b, a) } -// type F(type A, B) func(A, B) (B, A) +type F(type A, B) func(A, B) (B, A) -func min(type T)(x, y T) T { - //if x < y { - // return x - //} +func min(type T interface{ type int })(x, y T) T { + if x < y { + return x + } return y } +func _(type T interface{type int, float32})(x, y T) bool { return x < y } +func _(type T)(x, y T) bool { return x /* ERROR cannot compare */ < y } +func _(type T interface{type int, float32, bool})(x, y T) bool { return x /* ERROR cannot compare */ < y } + +func _(type T C1)(x, y T) bool { return x /* ERROR cannot compare */ < y } +func _(type T C2)(x, y T) bool { return x < y } + +contract C1(T) {} +contract C2(T) { T int, float32 } + func new(type T)() *T { var x T return &x diff --git a/src/go/types/type.go b/src/go/types/type.go index af56e87892..7536ab716b 100644 --- a/src/go/types/type.go +++ b/src/go/types/type.go @@ -259,7 +259,7 @@ func (t *Interface) is(pred func(Type) bool) bool { return false } } - return true + return len(t.allTypes) > 0 // we must have at least one type! (was bug) } // emptyInterface represents the empty (completed) interface