Skip to content

Commit 64b1889

Browse files
committed
test: new test for issue 30862
New test case, inspired by gccgo issue 30862. Updates #30862. Change-Id: I5e494b877e4fd142b8facb527471fe1fdef39c61 Reviewed-on: https://go-review.googlesource.com/c/go/+/167744 Run-TryBot: Than McIntosh <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent 156c830 commit 64b1889

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

test/fixedbugs/issue30862.dir/a.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2019 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 a
6+
7+
var pl int
8+
9+
type NoitfStruct struct {
10+
F int
11+
G int
12+
}
13+
14+
//go:nointerface
15+
func (t *NoitfStruct) NoInterfaceMethod() {}

test/fixedbugs/issue30862.dir/b.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2019 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 b
6+
7+
import "./a"
8+
9+
type EmbedImported struct {
10+
a.NoitfStruct
11+
}
12+
13+
func Test() []string {
14+
bad := []string{}
15+
x := interface{}(new(a.NoitfStruct))
16+
if _, ok := x.(interface {
17+
NoInterfaceMethod()
18+
}); ok {
19+
bad = append(bad, "fail 1")
20+
}
21+
22+
x = interface{}(new(EmbedImported))
23+
if _, ok := x.(interface {
24+
NoInterfaceMethod()
25+
}); ok {
26+
bad = append(bad, "fail 2")
27+
}
28+
return bad
29+
}

test/fixedbugs/issue30862.dir/main.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2019 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+
import (
8+
"fmt"
9+
"os"
10+
11+
"./b"
12+
)
13+
14+
// Test case for issue 30862.
15+
16+
// Be aware that unless GOEXPERIMENT=fieldtrack is set when building
17+
// the compiler, this test will fail if executed with a regular GC
18+
// compiler.
19+
20+
func main() {
21+
bad := b.Test()
22+
if len(bad) > 0 {
23+
for _, s := range bad {
24+
fmt.Fprintf(os.Stderr, "test failed: %s\n", s)
25+
}
26+
os.Exit(1)
27+
}
28+
}

test/fixedbugs/issue30862.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// rundir
2+
3+
// Copyright 2019 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Test case for issue 30862. This test as written will
8+
// fail for the main 'gc' compiler unless GOEXPERIMENT=fieldtrack
9+
// is set when building it, whereas gccgo has field tracking
10+
// enabled by default (hence the build tag below).
11+
12+
// +build gccgo
13+
14+
package ignored

0 commit comments

Comments
 (0)