Discovered that my previous change to eliminate reflection led to an abundance of generated classes. For the combination of the 6 targets and the 4 method types there were 24 classes generated where most were really duplicates.
Here is a patch that corrects that and reduces those 24 down to 6
diff --git a/src/main/kotlin/butterknife/ButterKnife.kt b/src/main/kotlin/butterknife/ButterKnife.kt
index 947b824..5611c25 100644
--- a/src/main/kotlin/butterknife/ButterKnife.kt
+++ b/src/main/kotlin/butterknife/ButterKnife.kt
@@ -9,60 +9,69 @@ import android.view.View
import kotlin.properties.ReadOnlyProperty
public fun <V : View> View.bindView(id: Int)
- : ReadOnlyProperty<View, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<View, V> = required(id, viewFinder)
public fun <V : View> Activity.bindView(id: Int)
- : ReadOnlyProperty<Activity, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<Activity, V> = required(id, viewFinder)
public fun <V : View> Dialog.bindView(id: Int)
- : ReadOnlyProperty<Dialog, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<Dialog, V> = required(id, viewFinder)
public fun <V : View> Fragment.bindView(id: Int)
- : ReadOnlyProperty<Fragment, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<Fragment, V> = required(id, viewFinder)
public fun <V : View> SupportFragment.bindView(id: Int)
- : ReadOnlyProperty<SupportFragment, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<SupportFragment, V> = required(id, viewFinder)
public fun <V : View> ViewHolder.bindView(id: Int)
- : ReadOnlyProperty<ViewHolder, V> = required(id, ::findViewById)
+ : ReadOnlyProperty<ViewHolder, V> = required(id, viewFinder)
public fun <V : View> View.bindOptionalView(id: Int)
- : ReadOnlyProperty<View, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<View, V?> = optional(id, viewFinder)
public fun <V : View> Activity.bindOptionalView(id: Int)
- : ReadOnlyProperty<Activity, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<Activity, V?> = optional(id, viewFinder)
public fun <V : View> Dialog.bindOptionalView(id: Int)
- : ReadOnlyProperty<Dialog, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<Dialog, V?> = optional(id, viewFinder)
public fun <V : View> Fragment.bindOptionalView(id: Int)
- : ReadOnlyProperty<Fragment, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<Fragment, V?> = optional(id, viewFinder)
public fun <V : View> SupportFragment.bindOptionalView(id: Int)
- : ReadOnlyProperty<SupportFragment, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<SupportFragment, V?> = optional(id, viewFinder)
public fun <V : View> ViewHolder.bindOptionalView(id: Int)
- : ReadOnlyProperty<ViewHolder, V?> = optional(id, ::findViewById)
+ : ReadOnlyProperty<ViewHolder, V?> = optional(id, viewFinder)
public fun <V : View> View.bindViews(vararg ids: Int)
- : ReadOnlyProperty<View, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<View, List<V>> = required(ids, viewFinder)
public fun <V : View> Activity.bindViews(vararg ids: Int)
- : ReadOnlyProperty<Activity, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<Activity, List<V>> = required(ids, viewFinder)
public fun <V : View> Dialog.bindViews(vararg ids: Int)
- : ReadOnlyProperty<Dialog, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<Dialog, List<V>> = required(ids, viewFinder)
public fun <V : View> Fragment.bindViews(vararg ids: Int)
- : ReadOnlyProperty<Fragment, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<Fragment, List<V>> = required(ids, viewFinder)
public fun <V : View> SupportFragment.bindViews(vararg ids: Int)
- : ReadOnlyProperty<SupportFragment, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<SupportFragment, List<V>> = required(ids, viewFinder)
public fun <V : View> ViewHolder.bindViews(vararg ids: Int)
- : ReadOnlyProperty<ViewHolder, List<V>> = required(ids, ::findViewById)
+ : ReadOnlyProperty<ViewHolder, List<V>> = required(ids, viewFinder)
public fun <V : View> View.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<View, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<View, List<V>> = optional(ids, viewFinder)
public fun <V : View> Activity.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<Activity, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<Activity, List<V>> = optional(ids, viewFinder)
public fun <V : View> Dialog.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<Dialog, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<Dialog, List<V>> = optional(ids, viewFinder)
public fun <V : View> Fragment.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<Fragment, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<Fragment, List<V>> = optional(ids, viewFinder)
public fun <V : View> SupportFragment.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<SupportFragment, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<SupportFragment, List<V>> = optional(ids, viewFinder)
public fun <V : View> ViewHolder.bindOptionalViews(vararg ids: Int)
- : ReadOnlyProperty<ViewHolder, List<V>> = optional(ids, ::findViewById)
+ : ReadOnlyProperty<ViewHolder, List<V>> = optional(ids, viewFinder)
-private fun Fragment.findViewById(id: Int): View? = getView().findViewById(id)
-private fun SupportFragment.findViewById(id: Int): View? = getView().findViewById(id)
-private fun ViewHolder.findViewById(id: Int): View? = itemView.findViewById(id)
+private val View.viewFinder: View.(Int) -> View?
+ get() = View::findViewById
+private val Activity.viewFinder: Activity.(Int) -> View?
+ get() = Activity::findViewById
+private val Dialog.viewFinder: Dialog.(Int) -> View?
+ get() = Dialog::findViewById
+private val Fragment.viewFinder: Fragment.(Int) -> View?
+ get() = { getView().findViewById(it) }
+private val SupportFragment.viewFinder: SupportFragment.(Int) -> View?
+ get() = { getView().findViewById(it) }
+private val ViewHolder.viewFinder: ViewHolder.(Int) -> View?
+ get() = { itemView.findViewById(it) }
private fun viewNotFound(id:Int, desc: PropertyMetadata) =
throw IllegalStateException("View ID $id for '${desc.name}' not found.")