better type inference for apply with unknown arguments. fixes #5327