Skip to content

Commit ed55da4

Browse files
committed
[dev.regabi] go/types: overlapping embedded interfaces requires go1.14
This is an exact port of CL 290911 to go/types. For #31793 Change-Id: I28c42727735f467a5984594b455ca58ab3375591 Reviewed-on: https://go-review.googlesource.com/c/go/+/291319 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 7696c94 commit ed55da4

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

src/go/types/stdlib_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func TestStdFixed(t *testing.T) {
185185
"issue22200b.go", // go/types does not have constraints on stack size
186186
"issue25507.go", // go/types does not have constraints on stack size
187187
"issue20780.go", // go/types does not have constraints on stack size
188-
"issue34329.go", // go/types does not have constraints on language level (-lang=go1.13) (see #31793)
189188
"bug251.go", // issue #34333 which was exposed with fix for #34151
190189
"issue42058a.go", // go/types does not have constraints on channel element size
191190
"issue42058b.go", // go/types does not have constraints on channel element size

src/go/types/testdata/go1_13.src

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2021 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+
// Check Go language version-specific errors.
6+
7+
package go1_13 // go1.13
8+
9+
// interface embedding
10+
11+
type I interface { m() }
12+
13+
type _ interface {
14+
m()
15+
I // ERROR "duplicate method m"
16+
}
17+
18+
type _ interface {
19+
I
20+
I // ERROR "duplicate method m"
21+
}
22+

src/go/types/typexpr.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,13 @@ func (check *Checker) completeInterface(ityp *Interface) {
578578
check.errorf(atPos(pos), _DuplicateDecl, "duplicate method %s", m.name)
579579
check.errorf(atPos(mpos[other.(*Func)]), _DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
580580
default:
581-
// check method signatures after all types are computed (issue #33656)
581+
// We have a duplicate method name in an embedded (not explicitly declared) method.
582+
// Check method signatures after all types are computed (issue #33656).
583+
// If we're pre-go1.14 (overlapping embeddings are not permitted), report that
584+
// error here as well (even though we could do it eagerly) because it's the same
585+
// error message.
582586
check.atEnd(func() {
583-
if !check.identical(m.typ, other.Type()) {
587+
if !check.allowVersion(m.pkg, 1, 14) || !check.identical(m.typ, other.Type()) {
584588
check.errorf(atPos(pos), _DuplicateDecl, "duplicate method %s", m.name)
585589
check.errorf(atPos(mpos[other.(*Func)]), _DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
586590
}

0 commit comments

Comments
 (0)