Skip to content

Non-definition prefix is in implicit scope, unlike Scala 2 #9094

Closed
@neko-kai

Description

@neko-kai

Minimized code

trait X {
  trait S
}

class Xa(val internal: X) {
  type S = internal.S
  def s: S = new S{}

  implicit class XS(s: S) {
    def printX: Unit = println(s)
  }
}

object Xa extends Xa(new X{})

object App extends App {
  Xa.s.printX
}

Output

    Xa$$anon$1@55924a6a

The above, unexpectedly, compiles and works with Dotty[1], but not with Scala 2.13[2]

Expectation

It seems like Xa is included in the implicit scope of type Xa.internal.S where Xa is not a direct prefix of S, but is instead only a prefix of its prefix, whereas Scala 2 does not include prefixes of prefixes in implicit scope, but only non-prefix parts of the direct prefix.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions