0
1
mirror of https://github.com/golang/go synced 2025-05-31 15:40:52 +00:00

allow conversion to interface type

when implicit assignment would have been okay.

R=ken
OCL=31225
CL=31227
This commit is contained in:
Russ Cox
2009-07-06 17:20:48 -07:00
parent 53ebd163c6
commit d436a70193
4 changed files with 22 additions and 10 deletions
src
test/interface

@ -15,13 +15,14 @@ type I interface { M() }
var i I
type I2 interface { M(); N(); }
var i2 I2;
var i2 I2
var e interface { };
type E interface { }
var e E
func main() {
e = t; // ok
t = e; // ERROR "need explicit"
t = e; // ERROR "need explicit|need type assertion"
// neither of these can work,
// because i has an extra method
@ -30,5 +31,11 @@ func main() {
t = i; // ERROR "missing|incompatible|is not"
i = i2; // ok
i2 = i; // ERROR "need explicit"
i2 = i; // ERROR "need explicit|need type assertion"
i = I(i2); // ok
i2 = I2(i); // ERROR "need explicit|need type assertion"
e = E(t); // ok
t = T(e); // ERROR "need explicit|need type assertion"
}