mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
compiler: add support for anonymous type asserts
This is used for example by the errors package, which contains:
if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) {
return true
}
The interface here is not a named type.
This commit is contained in:
committed by
Ron Evans
parent
cc4a4c755f
commit
0596b3c003
Vendored
+3
@@ -26,6 +26,9 @@ func main() {
|
||||
println("Stringer.String():", s.String())
|
||||
var itf interface{} = s
|
||||
println("Stringer.(*Thing).String():", itf.(Stringer).String())
|
||||
if s, ok := s.(interface{ String() string }); ok {
|
||||
println("s has String() method:", s.String())
|
||||
}
|
||||
|
||||
println("nested switch:", nestedSwitch('v', 3))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user