The UK should be able to unilaterally revoke its withdrawal from the EU, according to a top European law officer.