Huh. I got the behavior that I didn't expect. Ther...
# announcements
d
Huh. I got the behavior that I didn't expect. There are two classes and the interface:
Copy code
class View {
		void setNestedScrollingEnabled(boolean enabled)
	}
	interface NestedScrollingView {
		void setNestedScrollingEnabled(boolean enabled)
	}
	class RecyclerView extends View implements NestedScrollingView {
		@Override
		void setNestedScrollingEnabled(boolean enabled)
	}
and my code:
Copy code
val list: View = view.findViewById(R.id.list)
if (list is RecyclerView) {
	list.setNestedScrollingEnabled(false)
}
And here, when I'm calling the method, on some platforms I'm getting NoSuchMethod exception. The answer is simple:
View.setNestedScrollingEnabled
is implemented only for newer versions of the system framework. But
RecyclerView.setNestedScrollingEnabled
is always available. When I write
list.setNestedScrollingEnabled
I'm expecting a call to RecyclerView's method, via smart-casting, but a call to View's method is generated. I've searched, but didn't find anything about this smart-cast's behavior in the language documentation 🙁