diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index 4065fb124e..cf5798d6d1 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -130,6 +130,7 @@ var tests = [][]string{ {"fixedbugs/issue39680.go2"}, {"fixedbugs/issue39711.go2"}, {"fixedbugs/issue39723.go2"}, + {"fixedbugs/issue39754.go2"}, {"fixedbugs/issue39755.go2"}, {"fixedbugs/issue39768.go2"}, } diff --git a/src/go/types/fixedbugs/issue39754.go2 b/src/go/types/fixedbugs/issue39754.go2 new file mode 100644 index 0000000000..64ce3049ff --- /dev/null +++ b/src/go/types/fixedbugs/issue39754.go2 @@ -0,0 +1,25 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type Optional(type T) struct { + p T + set bool +} + +func (o Optional(T)) Val() (T, bool) { + return o.p, true +} + +type Box(type T) interface { + Val() (T, bool) +} + +func F1(type V interface{}, A, B Box(V))() {} + +func main() { + F1(int, Optional(int), Optional(int))() + F1(int, Optional(int), Optional(string) /* ERROR "does not satisfy Box(V) (missing method Val)" */)() +} \ No newline at end of file diff --git a/src/go/types/subst.go b/src/go/types/subst.go index 64418bfed6..47622b7c39 100644 --- a/src/go/types/subst.go +++ b/src/go/types/subst.go @@ -177,7 +177,7 @@ func (check *Checker) instantiate(pos token.Pos, typ Type, targs []Type, poslist // targ's underlying type must also be one of the interface types listed, if any if iface.allTypes == nil { - break // nothing to do + continue // nothing to do } // iface.allTypes != nil