Fixes #8761. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews, r https://golang.org/cl/144530045