fix type detection for forward-declared functions

introduced in 1cb89e2735e5c62fb8a3b9aede23a2f3cd8670f7