[Vala] What is correct solution to warning: 'null' incompatible with 'SomeType'?



Hello Folks,

I am writing a function and I need it to return null if all else failed
(in fact is should never happen, because I covered all cases by a switch,
but valac can't see that, so I need a default return there). Now if I just
write:
    return null;
it gives me a warning:
    Shell.vala:112.13-112.24: warning: `null' incompatible with return type
    `Guitcore.Task`
            return null;
            ^^^^^^^^^^^^
But if I write:
    return (Guitcore.Task)null;
I get the cast actually generated into C code, taking ref if the result is
not null etc, which is obviously useless there. So what is the right way to
write it?

Best regards,
Jan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]