hasn
hasn

Reputation: 797

How to disable smart cast highlight Kotlin?

IDE : Android Studio 3.3

I am doing kotlin smart casting in RecyclerView adapter on ViewHolder.

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        holder as ViewHolder

Now every mention of viewholder is being highlighted, with text on hover saying "Smart Cast to ..." This is not a problem but really annoying. How can I disable this highlight feature?

screenshot

Upvotes: 15

Views: 1271

Answers (3)

hotkey
hotkey

Reputation: 147961

In the IDE prefererences, see:

Editor → Color scheme → Kotlin → Smart-casts → Smart-cast value

If you want to disable value smart-cast highlighting, just uncheck Background.

You may want to configure the other kinds of smart-casts, too.

enter image description here

Upvotes: 19

Dominic Fischer
Dominic Fischer

Reputation: 1849

Instead of just using holder as ViewHolder, try using if (holder !is ViewHolder) throw Exception() or if (holder !is ViewHolder) return.

Upvotes: 0

Sahil
Sahil

Reputation: 972

go to File -> Settings -> Editor -> Color Scheme -> Java/Kotlin -> Classes and Interfaces

You should be able to find color scheme for classes here. Hope it helps.

Upvotes: 1

Related Questions