diff options
author | Robert Griesemer <gri@golang.org> | 2020-12-01 17:37:12 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2020-12-03 17:55:56 +0000 |
commit | 7a1aa7dfaf9a7208a6cae7518037d885c9fabdbd (patch) | |
tree | aa509df6b2972df2bb5e86af12d5c5d6a4989c67 /test/interface | |
parent | 07d32c8183eb4f7d8d1d6185ea69b8fb0425f6a6 (diff) | |
download | go-7a1aa7dfaf9a7208a6cae7518037d885c9fabdbd.tar.gz go-7a1aa7dfaf9a7208a6cae7518037d885c9fabdbd.zip |
[dev.typeparams] test: adjust more test cases to match compiler -G output
With this CL, the first ~500 errorcheck tests pass when running
go run run.go -v -G
in the $GOROOT/test directory (the log output includes a few dozen
tests that are currently skipped).
Change-Id: I9eaa2319fb39a090df54f8699ddc29ffe58b1bf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/274975
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'test/interface')
-rw-r--r-- | test/interface/embed2.go | 10 | ||||
-rw-r--r-- | test/interface/explicit.go | 22 | ||||
-rw-r--r-- | test/interface/pointer.go | 4 | ||||
-rw-r--r-- | test/interface/receiver1.go | 4 |
4 files changed, 23 insertions, 17 deletions
diff --git a/test/interface/embed2.go b/test/interface/embed2.go index df3e2e435b..97a2d963f0 100644 --- a/test/interface/embed2.go +++ b/test/interface/embed2.go @@ -48,25 +48,25 @@ func main() { check("t.M()", t.M()) check("pt.M()", pt.M()) check("ti.M()", ti.M()) - check("pti.M()", pti.M()) // ERROR "pointer to interface, not interface" + check("pti.M()", pti.M()) // ERROR "pointer to interface, not interface|no field or method M" check("s.M()", s.M()) check("ps.M()", ps.M()) i = t check("i = t; i.M()", i.M()) - check("i = t; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" + check("i = t; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M" i = pt check("i = pt; i.M()", i.M()) - check("i = pt; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" + check("i = pt; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M" i = s check("i = s; i.M()", i.M()) - check("i = s; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" + check("i = s; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M" i = ps check("i = ps; i.M()", i.M()) - check("i = ps; pi.M()", pi.M()) // ERROR "pointer to interface, not interface" + check("i = ps; pi.M()", pi.M()) // ERROR "pointer to interface, not interface|no field or method M" if !ok { println("BUG: interface10") diff --git a/test/interface/explicit.go b/test/interface/explicit.go index 1fb3b6a05a..7aaaad4e48 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -38,7 +38,7 @@ var e E func main() { e = t // ok - t = e // ERROR "need explicit|need type assertion" + t = e // ERROR "need explicit|need type assertion|incompatible type" // neither of these can work, // because i has an extra method @@ -47,17 +47,17 @@ func main() { t = i // ERROR "incompatible|assignment$" i = i2 // ok - i2 = i // ERROR "incompatible|missing N method" + i2 = i // ERROR "incompatible|missing N method|cannot convert" i = I(i2) // ok - i2 = I2(i) // ERROR "invalid|missing N method" + i2 = I2(i) // ERROR "invalid|missing N method|cannot convert" e = E(t) // ok - t = T(e) // ERROR "need explicit|need type assertion|incompatible" + t = T(e) // ERROR "need explicit|need type assertion|incompatible|cannot convert" // cannot type-assert non-interfaces f := 2.0 - _ = f.(int) // ERROR "non-interface type" + _ = f.(int) // ERROR "non-interface type|not an interface type" } @@ -83,8 +83,8 @@ var jj Int var m1 M = ii // ERROR "incompatible|missing" var m2 M = jj // ERROR "incompatible|wrong type for M method" -var m3 = M(ii) // ERROR "invalid|missing" -var m4 = M(jj) // ERROR "invalid|wrong type for M method" +var m3 = M(ii) // ERROR "invalid|missing|cannot convert" +var m4 = M(jj) // ERROR "invalid|wrong type for M method|cannot convert" type B1 interface { _() // ERROR "methods must have a unique non-blank name" @@ -101,5 +101,9 @@ func (t *T2) M() {} func (t *T2) _() {} // Check that nothing satisfies an interface with blank methods. -var b1 B1 = &T2{} // ERROR "incompatible|missing _ method" -var b2 B2 = &T2{} // ERROR "incompatible|missing _ method" +// Disabled this test as it's not clear we need this behavior. +// See also issue #42964. +/* +var b1 B1 = &T2{} // "incompatible|missing _ method" +var b2 B2 = &T2{} // "incompatible|missing _ method" +*/
\ No newline at end of file diff --git a/test/interface/pointer.go b/test/interface/pointer.go index 2927050669..c21e4da390 100644 --- a/test/interface/pointer.go +++ b/test/interface/pointer.go @@ -32,7 +32,9 @@ func AddInst(Inst) *Inst { func main() { print("call addinst\n") - var x Inst = AddInst(new(Start)) // ERROR "pointer to interface" + var x Inst = AddInst(new(Start)) // ERROR "pointer to interface|incompatible type" + _ = x print("return from addinst\n") var y *Inst = new(Start) // ERROR "pointer to interface|incompatible type" + _ = y } diff --git a/test/interface/receiver1.go b/test/interface/receiver1.go index 2b7ccdc1a7..a0a87534a4 100644 --- a/test/interface/receiver1.go +++ b/test/interface/receiver1.go @@ -37,14 +37,14 @@ func main() { var sp SP v = t - p = t // ERROR "does not implement|requires a pointer" + p = t // ERROR "does not implement|requires a pointer|cannot use" _, _ = v, p v = &t p = &t _, _ = v, p v = s - p = s // ERROR "does not implement|requires a pointer" + p = s // ERROR "does not implement|requires a pointer|cannot use" _, _ = v, p v = &s p = &s |