Skip to content

Commit bf418db

Browse files
committed
[dev.go2go] go/types: fix type check skipping for constraints when there’s more than one generic constraint.
Fixes golang#39754.
1 parent 4dfbf5a commit bf418db

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/go/types/check_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ var tests = [][]string{
130130
{"fixedbugs/issue39680.go2"},
131131
{"fixedbugs/issue39711.go2"},
132132
{"fixedbugs/issue39723.go2"},
133+
{"fixedbugs/issue39754.go2"},
133134
{"fixedbugs/issue39755.go2"},
134135
{"fixedbugs/issue39768.go2"},
135136
}

src/go/types/fixedbugs/issue39754.go2

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
type Optional(type T) struct {
8+
p T
9+
set bool
10+
}
11+
12+
func (o Optional(T)) Val() (T, bool) {
13+
return o.p, true
14+
}
15+
16+
type Box(type T) interface {
17+
Val() (T, bool)
18+
}
19+
20+
func F1(type V interface{}, A, B Box(V))() {}
21+
22+
func main() {
23+
F1(int, Optional(int), Optional(int))()
24+
F1(int, Optional(int), Optional(string) /* ERROR "does not satisfy Box(V) (missing method Val)" */)()
25+
}

src/go/types/subst.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (check *Checker) instantiate(pos token.Pos, typ Type, targs []Type, poslist
177177

178178
// targ's underlying type must also be one of the interface types listed, if any
179179
if iface.allTypes == nil {
180-
break // nothing to do
180+
continue // nothing to do
181181
}
182182
// iface.allTypes != nil
183183

0 commit comments

Comments
 (0)