可以在这样一个带注释的类型上定义Kotlin扩展函数吗?
@ColorInt
fun @ColorInt Int.darken(): Int {
return ColorUtils.blendARGB(this, Color.BLACK, 0.2f)
}
替代形式:
@ColorInt
fun (@ColorInt Int).darken(): Int {
return ColorUtils.blendARGB(this, Color.BLACK, 0.2f)
}
这将对应于以下静态功能:
@ColorInt
fun darken(@ColorInt color: Int): Int {
return ColorUtils.blendARGB(color, Color.BLACK, 0.2f)
}
I don't think that's possible yet using Kotlin, but would it be possible to add that feature in later Kotlin versions?
另一方面: