Fix ICE when calling static and static function pointers

Fixes #8588