are there any plans to improve the “Find Usages” i...
# intellij
z
are there any plans to improve the “Find Usages” in IntelliJ/Android Studio for a
typealias
? For example,
typealias LoadString: () -> String
finds all usages of
() -> T
and I specifically just want
LoadString
m
Given that a typealias is just a convenience/alias, IJ/AS are strictly doing the right thing as anywhere LoadString is used, a
() -> String
can be used. So, I think you're stuck with text search, or filtering what IntelliJ returns.
z
I’m aware why this is an issue, but until it’s fixed, using functional types to avoid extra class definitions make code discovery and reading more difficult
m
I believe there's a keep for providing Higher-kinded types. Inline classes are also attempting to address this, but not helpful for your scenario. So yes, there are still gaping holes in writing FP code in Kotlin...
a
Failed to reproduce for code:
Copy code
typealias LoadString = () -> String

fun foo(l: LoadString) {}
fun <T> bar(l: () -> T) {}
Can you please create an issue at http://kotl.in/issue with a self-contained code sample to reproduce?
z
@Alexey Belkov [JB] - find usages works, but it does not treat the following as different types:
Copy code
typealias LoadFavoriteColor = () -> String
typealias LoadFavoriteName = () -> String
which creates a pain point for those looking to replace SAM interfaces with with functional types
With the cursor on
LoadFavoriteColor
on mac,
cmd
+
option
+
B
should navigate to an implementation of
LoadFavoriteColor
overall what I’m asking for is a developer experience for functional type aliases that’s on par with with SAM interfaces
a
1. Sorry, I don't understand your comment "find usages works, but it does not treat the following as different types". Can you please share a code sample with detailed steps to reproduce? 2. So, do you propose that "Go to implementations" should work here for
LoadString
? Or do you have some different case in mind?
Copy code
typealias LoadString = () -> String

class Foo : LoadString {
    override fun invoke(): String = TODO()
}