diff --git a/libraries/stdlib/src/kotlin/properties/Interfaces.kt b/libraries/stdlib/src/kotlin/properties/Interfaces.kt index 07896aeb67c..55b6579e123 100644 --- a/libraries/stdlib/src/kotlin/properties/Interfaces.kt +++ b/libraries/stdlib/src/kotlin/properties/Interfaces.kt @@ -52,3 +52,27 @@ public interface ReadWriteProperty { */ public operator fun setValue(thisRef: R, property: KProperty<*>, value: T) } + +/** + * Base interface that can be used for implementing property delegate providers. + * + * This is provided only for convenience; you don't have to extend this interface + * as long as your delegate provider has a method with the same signature. + * + * @param T the type of object which owns the delegated property. + * @param D the type of property delegates this provider provides. + */ +@SinceKotlin("1.4") +public interface PropertyDelegateProvider { + /** + * Returns the delegate of the property for the given object. + * + * This function can be used to extend the logic of creating the object (e.g. perform validation checks) + * to which the property implementation is delegated. + * + * @param thisRef the object for which property delegate is requested. + * @param property the metadata for the property. + * @return the property delegate. + */ + public operator fun provideDelegate(thisRef: T, property: KProperty<*>): D +}