I have learned that Open Close Principle is allowing extension to classes and restricting from modification. So in Kotlin, when we use extension function
I assume extension means to apply inheritance and modification means to add or change code of existing class.
Thanks
'Extension' in the context of the Open Closed Principle usually does not mean inheritance, it means somehow extending the class with new functionality. 'Modification' does refer to changing the code of the class, as you say.
The extension facility of Kotlin allows you to add a method to a class without editing the code of the class. This is perfectly in keeping with the Open Closed Principle -- the class is extended with new functionality without the class itself being changed.