Skip to content

Record intersection selections have no hover #22919

Open
@scarf005

Description

@scarf005

Compiler version

3.7.0-RC1

Minimized code

type A = Record {val a: Int}
type B = Record {val b: String}
type AB = A & B

// from https://docs.scala-lang.org/scala3/reference/changed-features/structural-types.html
class Record(elems: (String, Any)*) extends Selectable:
  private val fields = elems.toMap
  def selectDynamic(name: String): Any = fields(name)

val a: A = Record("a" -> 1).asInstanceOf[A]
val a_a = a.a
//          ^ hover here (val a: Int)

val ab: AB = Record("a" -> 1, "b" -> "hello").asInstanceOf[AB]
val ab_a = ab.a
//            ^ hover here (nothing)

Output

  • for a, the hover shows val a: Int
  • for ab, it shows nothing

Expectation

I'd expect to see a: Int when hovering, as merging two types into a new type is a common operation in structurally typed language (e.g typescript).

equivalent code in typescript

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:presentation-compilerRelated to the presentation compiler module used by Metals and possibly other toolsitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions