Probably I am missing something fundamental here, but I was refactoring certain things in my code and on the halfway I noticed that my code compiles, where I would expect it would not. So here is the method signature:
def checkUiFieldValue[T](fieldName:String, uiValue:T, expectedValue:T):Unit ={...}
Here is a place where it is used:
checkUiFieldValue("State", stateInListView(ar.name), ar.state)
The return type of the stateInListView is ARState class, while the type of the ar.state is String.
So question is why does it compile and does not tell me that types do not match? I caught myself with a thought that I expect that compiler would check that uiValue and expectedValue are of the same type T but probably my assumption is incorrect.
Or type parameter T in the method definition actually means that both arguments will be casted to Any in my case? If so then how should I properly restrict both args to have the same type at compile time?