Type inference failed: Not enough information to infer parameter T in fun <T : View!> findViewById(p0: Int): T! Please specify it explicitly.

今日ひさしぶりにAndroid Studioを開いてみたらビルドエラーが発生

findViewByIdでエラーの模様

Type inference failed: Not enough information to infer parameter T in fun <T : View!> findViewById(p0: Int): T!
Please specify it explicitly. 

kotlinで書いていたが以下のように書き直し

javaでも同様のエラーでるようになったのかな?

view.findViewById(R.id.item)

view.findViewById<View>(R.id.item)

 

キャスト付き

root.findViewById(R.id.text) as TextView

↓ 

root.findViewById<TextView>(R.id.text)