[BUGFIX release] Fix hasThis lookup regression

Also optimizes lookup using lastIndexOf(x, 0), resulting in a constant time lookup
Merge pull request #9991 from kanongil/this-path-fix

Fix hasThis lookup regression