fix(autoload): correct detection of traits in autoload (closes #4713)