-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Milestone
Description
Coming from #41882, @ianlancetaylor suggests adding:
func IsEmptyInterface(t reflect.Type) bool
to reflect package to detect empty interface.
Currently, users (including standard libraries, Google internal code, are relying on reflect.Type.NumMethod() == 0 to check empty interface, which is wrong. After #22075 is fixed, code which uses wrong behavior should be changed to:
reflect.TypeOf((*interface{})(nil)).Elem().Implements(T)
Adding reflect.IsEmptyInterface will help user's migration easier.
zigo101, mcdoker18, mvdan, josharian, mdempsky and 1 more