Fix resolving ref against resolution scope

@titanous