From bf418db782d82fa48d04ffe9ce03c860089c7014 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Sun, 28 Jun 2020 23:28:08 +0300 Subject: [PATCH] =?UTF-8?q?[dev.go2go]=20go/types:=20fix=20type=20check=20?= =?UTF-8?q?skipping=20for=20constraints=20when=20there=E2=80=99s=20more=20?= =?UTF-8?q?than=20one=20generic=20constraint.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #39754. --- src/go/types/check_test.go | 1 + src/go/types/fixedbugs/issue39754.go2 | 25 +++++++++++++++++++++++++ src/go/types/subst.go | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/go/types/fixedbugs/issue39754.go2 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