Is it Scottish or European law?
It's not European law. I know that because in Ireland, which is an EU country, only Irish citizens may vote in referendums. That's because the result of a referendum requires a change in the constitution and only the citizens of Ireland have the power to change our constitution.
I don't believe it's Scottish law either as the referendum is not called by Scotland but by Westminster ie the British government decides that there will be a referendum, therefore Westminster decides the voting eligibility. As there is virtually no history of referendums in the UK (as opposed to Ireland where we've had about thirty, if memory serves me correctly) I think the voting rights are decided on a case by case basis.
As to Poland, you don't have many referendums either and your government doesn't need to consult citizens to change the constitution so the issue of foreigners voting in Polish referendums is not likely to arise.