I think you're asking the question in relation to Java.
In Java and many other strongly typed languages (just to name a few: C/C++, C#), a function can only return with one type of an object.
ReturnType Function(ArgumentType1 argument1, ArgumentType2 argument2, ...);
So when you defined your function, may it return void (nothing) or built-in types, or a user-defined type, it only can return that type. So the compiler can check if the variable that takes the value of this method is compatible to store something that is returned by the method.
You do not make the compiler check for integral type. Instead, you look at the return value of the function and check if it is indeed an integral type.