]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: require -lang=go1.14 for overlapping interfaces
authorMatthew Dempsky <mdempsky@google.com>
Mon, 16 Sep 2019 18:28:05 +0000 (11:28 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 16 Sep 2019 19:43:54 +0000 (19:43 +0000)
Support for overlapping interfaces is a new (proposed) Go language
feature to be supported in Go 1.14, so it shouldn't be supported under
-lang=go1.13 or earlier.

Fixes #34329.

Change-Id: I5fea5716b7d135476980bc40b4f6e8c611b67735
Reviewed-on: https://go-review.googlesource.com/c/go/+/195678
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/align.go
src/go/types/stdlib_test.go
test/fixedbugs/issue34329.go [new file with mode: 0644]

index d6251adc7a402ebb7a4379ed79e7cca2ca81160d..bd6176e4794d4f6f348fd76505c4b4c6d40b4c17 100644 (file)
@@ -34,7 +34,7 @@ func expandiface(t *types.Type) {
                switch prev := seen[m.Sym]; {
                case prev == nil:
                        seen[m.Sym] = m
-               case !explicit && types.Identical(m.Type, prev.Type):
+               case langSupported(1, 14) && !explicit && types.Identical(m.Type, prev.Type):
                        return
                default:
                        yyerrorl(m.Pos, "duplicate method %s", m.Sym.Name)
index 771f54d3f1cef42def6bdc1a50ba4a609e4c01b9..a3cbe95b3a820cf4242a2a812aff394dc3c9661f 100644 (file)
@@ -181,6 +181,7 @@ func TestStdFixed(t *testing.T) {
                "issue25507.go",  // go/types does not have constraints on stack size
                "issue20780.go",  // go/types does not have constraints on stack size
                "issue31747.go",  // go/types does not have constraints on language level (-lang=go1.12) (see #31793)
+               "issue34329.go",  // go/types does not have constraints on language level (-lang=go1.13) (see #31793)
        )
 }
 
diff --git a/test/fixedbugs/issue34329.go b/test/fixedbugs/issue34329.go
new file mode 100644 (file)
index 0000000..790686e
--- /dev/null
@@ -0,0 +1,14 @@
+// errorcheck -lang=go1.13
+
+// Copyright 2019 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 p
+
+type I interface { M() }
+
+type _ interface {
+       I
+       I // ERROR "duplicate method M"
+}