mirror of https://github.com/golang/go.git
go/types: a type arg type list must be a subset of the type param type list
The original implementation (commit 65377ae6e0) checked the wrong way around. Added more tests. Change-Id: I59e1fd6d7e646f2e8e0ff68a0bbcf9ff9def0eff
This commit is contained in:
parent
a30fb05aa2
commit
d49c915592
|
|
@ -53,6 +53,8 @@ type AltGraph (type Node NodeFace(Edge), Edge EdgeFace(Node)) struct { }
|
|||
|
||||
func AltNew (type Node NodeFace(Edge), Edge EdgeFace(Node)) (nodes []Node) *AltGraph(Node, Edge) { panic("unimplemented") }
|
||||
|
||||
// func (g *AltGraph(N, E)) ShortestPath(from, to N) []E { panic("unimplemented") }
|
||||
|
||||
type NodeFace(type Edge) interface {
|
||||
Edges() []Edge
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,12 +97,11 @@ func (check *Checker) instantiate(pos token.Pos, typ Type, targs []Type, poslist
|
|||
break // nothing to do
|
||||
}
|
||||
|
||||
// if targ is a type parameter, the list of iface types must be a subset of the
|
||||
// list of targ types
|
||||
if t, _ := targ.Underlying().(*TypeParam); t != nil {
|
||||
targFace := t.Interface()
|
||||
for _, t := range iface.types {
|
||||
if !includesType(t, targFace) {
|
||||
// if targ is itself a type parameter, each of its possible types must be in the
|
||||
// list of iface types (i.e., the targ type list must be a subset of the iface types)
|
||||
if targ, _ := targ.Underlying().(*TypeParam); targ != nil {
|
||||
for _, t := range targ.Interface().types {
|
||||
if !includesType(t, iface) {
|
||||
check.softErrorf(pos, "%s does not satisfy %s (missing type %s)", targ, tpar.bound, t)
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,13 +202,19 @@ type T3(type P B1) P
|
|||
|
||||
func _(type P B1)(x T3(P))
|
||||
|
||||
contract B2(T) {
|
||||
T int
|
||||
|
||||
type B2 interface{type int, string}
|
||||
|
||||
func _(type P B2)(x T3(P /* ERROR missing type string */ ))
|
||||
|
||||
|
||||
contract B3(T) {
|
||||
T int, string
|
||||
}
|
||||
|
||||
type T4(type P B2) P
|
||||
type T4(type P B1) P
|
||||
|
||||
func _(type P B2)(x T4(P))
|
||||
func _(type P B3)(x T4(P /* ERROR missing type string */ ))
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Type parameters may be from different parameterized objects
|
||||
|
|
|
|||
|
|
@ -3,22 +3,3 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
|
||||
contract C(T) {
|
||||
T int
|
||||
}
|
||||
|
||||
type Cm(type T C) T
|
||||
|
||||
func (a Cm(T /* ERROR does not satisfy */ )) m() T
|
||||
|
||||
// TODO(gri) make this work
|
||||
/*
|
||||
type C interface {
|
||||
type int
|
||||
}
|
||||
|
||||
type Cm(type T C) T
|
||||
|
||||
func (a Cm(T)) m() T
|
||||
*/
|
||||
Loading…
Reference in New Issue