in reply to Class->can() bug or user error

The code doesn't do what you want, so of course there's a bug. The bug is in your code, though. Fixes:

'main'->can("bar")
main::->can("bar")