today got interesting confusion Method accepting p...
# announcements
o
today got interesting confusion Method accepting parameter as Any type, and by kotlin syntax definition client invoked this method not with round brackets but with curly brackets, and as type is Any, the syntax and compiler accepted it and method was invoked with closure type, which broke the runtime Is it possible somehow to restrict or avoid such behaviour on compile time level?
s
What was the error ?
s
yeah what do you mean by “broke the runtime”
I just tried this in a scratch file, no errors
w
I assume the error was that function that accepted
Any
was working with an assumption that that the parameter would be of non-functional type?
c
Sounds like something the code should just deal with - it is accepting "Any" after all. Maybe an inspection could be created that warns the developer, but I'm not sure the compiler should be getting involved here
o
yea, found the solution
add the second parameter with default value, then it's not possible to send closure by accident
s
that sounds like a pretty roundabout solution
that doesn’t exactly address the core issue
😂 1
1