mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +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 ?")
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -16,6 +16,7 @@ is Tuple: 1 7 11 13
|
||||
ArrayStruct.Print: 4 3
|
||||
is Tuple: 0 8 16 24
|
||||
SmallPair.Print: 3 5
|
||||
is nil
|
||||
Stringer.String(): foo
|
||||
Stringer.(*Thing).String(): foo
|
||||
s has String() method: foo
|
||||
|
||||
Reference in New Issue
Block a user