mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 03:53:42 +00:00
compiler: reimplement interface type asserts
This is a big reimplementation that simplifies the compiler a lot. Instead of storing the method set in metadata and lowering the type asserts as a whole program pass, this change just puts the list of methods in the type code (and a separate global for the interface type).
This commit is contained in:
Vendored
+3
@@ -22,6 +22,7 @@ func main() {
|
||||
printItf(array)
|
||||
printItf(ArrayStruct{3, array})
|
||||
printItf(SmallPair{3, 5})
|
||||
printItf(nil)
|
||||
s := Stringer(thing)
|
||||
println("Stringer.String():", s.String())
|
||||
var itf interface{} = s
|
||||
@@ -150,6 +151,8 @@ func printItf(val interface{}) {
|
||||
println("is struct{n int `foo:\"bar\"`}")
|
||||
case Foo:
|
||||
println("is Foo:", val)
|
||||
case nil:
|
||||
println("is nil")
|
||||
default:
|
||||
println("is ?")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user