fix bug in IR regarding type aliases

This commit is contained in:
Jaden Weiss
2019-09-19 23:38:16 -04:00
committed by Ron Evans
parent cf2a7b5089
commit 7732c6f449
3 changed files with 45 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package main
type x struct{}
func (x x) name() string {
return "x"
}
type y = x
type a struct {
n int
}
func (a a) fruit() string {
return "apple"
}
type b = a
type fruit interface {
fruit() string
}
type f = fruit
func main() {
// test a basic alias
println(y{}.name())
// test using a type alias value as an interface
var v f = b{}
println(v.fruit())
// test comparing an alias interface with the referred-to type
println(a{} == b{})
println(a{2} == b{3})
}