Closed
Description
Compiler version
3.1.1
Minimized code
class Structural(map: Map[String, Any]) extends Selectable:
def selectDynamic(name: String) = map(name)
type Person = Structural { val: name; val age: Int }
val p = new Structural(Map("name" -> "jacob", "age" -> 5)).asInstanceOf[Person]
p.name //I should see name + age in autocomplete
Output
There is no autocomplete for name
or age
.
Expectation
It would be great if there were autocomplete for name
and age
😄
Notes
I've copied this issue from a metals issue after being informed that it may make more sense here (scalameta/metals-feature-requests#238).
My hopes are that autocomplete for Selectable types can help provide a suitable replacement for annotation macros. I'm imagining a Macro that would generate a refined Selectable
type. This Selectable instance would be a bag of autocompleteable methods based upon the structure of the given case class. Generating Lenses, for instance, could look like this:
case class Person(name: String, age: Int)
object Person {
val lenses = Lenses.gen[Person]
}
Person.lenses.name // For this to be tenable, this would need to autocomplete with the type Lens[Person, String]