Fixed: @ref did not generate self.x for an ivar x

This fixes #2268

Thanks @kevin-xu