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:
Ayke van Laethem
2024-07-29 14:16:10 +02:00
parent 6184a6cd35
commit 19e2d12517
18 changed files with 467 additions and 436 deletions
+3
View File
@@ -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 ?")
}