allow direct conversion between string and named []byte, []rune
The allowed conversions before and after are:
type Tstring string
type Tbyte []byte
type Trune []rune
string <-> string // ok
string <-> []byte // ok
string <-> []rune // ok
string <-> Tstring // ok
string <-> Tbyte // was illegal, now ok
string <-> Trune // was illegal, now ok
Tstring <-> string // ok
Tstring <-> []byte // ok
Tstring <-> []rune // ok
Tstring <-> Tstring // ok
Tstring <-> Tbyte // was illegal, now ok
Tstring <-> Trune // was illegal, now ok
Update spec, compiler, tests. Use in a few packages.
We agreed on this a few months ago but never implemented it.
Fixes #1707.
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5421057
diff --git a/test/convlit.go b/test/convlit.go
index 2e3b15b..1e82d1f 100644
--- a/test/convlit.go
+++ b/test/convlit.go
@@ -54,12 +54,12 @@
var _ []rune = ss // ERROR "cannot use|incompatible|invalid"
var _ []byte = ss // ERROR "cannot use|incompatible|invalid"
-// named slice is not
+// named slice is now ok
type Trune []rune
type Tbyte []byte
-var _ = Trune("abc") // ERROR "convert|incompatible|invalid"
-var _ = Tbyte("abc") // ERROR "convert|incompatible|invalid"
+var _ = Trune("abc") // ok
+var _ = Tbyte("abc") // ok
// implicit is still not
var _ Trune = "abc" // ERROR "cannot use|incompatible|invalid"