forcetypeassert
forcetypeassert copied to clipboard
Can't detect forced type assertions followed by method calls
Consider the following code:
type M struct{}
func (M) F() (bool, bool) { return true, true }
func Test(x any) bool {
_, ok := x.(M).F()
return ok
}
The x.(M)
is a forced type assertion, but the subsequent .F()
masks the problem.