removes duplication in inferImplicitValue

This is a port of https://github.com/scala/scala/commit/4e64a2731d from 2.10.x.