code_typewarn: improve detection of module-scoped calls

Fewer false negatives this way
Use isleaftype in code_typewarn

This simplifies and broadens the logic considerably