Roth IRA earnings on late excess contribution: taxable in which year?

I made a late contribution to a Roth IRA in February 2018 for tax year 2017. Because this contribution is in excess, I now need to withdraw it. However, because I made the contribution in calendar year 2018, I am not entirely clear in which tax year the earnings on excess contribution will be taxable. Publication 590-A (2019) says:

 

How to treat withdrawn interest or other income.

You must include in your gross income the interest or other income that was earned on the excess contribution. Report it on your return for the year in which the excess contribution was made.

 

Since contribution was made *in* 2018 but *for* 2017, which tax year should I amend ? If it is consistent with 5329 form regarding the 6% excise tax, where line 23 says I need to report the excess contribution for 2017, then I am guessing that amending tax return 2017 for the earnings in this case is also the correct answer, but he language of the publication above seems vague to me and open to both interpretations. 

 

Thanks for any clarifications.