How am I supposed to get rid of the null-ability of function value?

There are a few problems with your code, where I don’t understand why you chose to do it this way.
First

if(defaultCalculator == null)
     return null!!

looking at documentation of !! you see that it throws an exception if the value is null so this code is the same as

if(defaultCalculator == null) throw NullPointerException()

If this is what you want than throw an exception. Don’t use !!.

__

That said I can’t reproduce your compiler error. Your code works fine for me. Normally I would say you can change defaultCalculator!!(key) to defaultCalculator(key) since you did the null check above, but there seems to be a bug in kotlin with generics(https://youtrack.jetbrains.com/issue/KT-29911) so you have to keep the !! for now.