scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Unable to introduce packaging _root_._root_ #12508

Open som-snytt opened 2 years ago

som-snytt commented 2 years ago

reproduction steps

Scala 2.13.7 and 3 differ as to whether these packagings are erroneous:

package _root_ {
  class C {
    val _root_ = 42
  }
}
package _root_.p {
  class C
}

Scala 2 is definitely wrong in rejecting _root_, as the spec is now clear that only the selection _root_.x makes _root_ mean the root package.

Once _root_ is defined, possibly the second packaging should put p.C in it. Scala 2 warns about such a case:

// neg/t6217c.scala
package a {
  package _root_ {
    object X
  }
  package _root_.p {
    object Y
  }
}

Scala 3 compiles the first example but not the second.

problem

The versions ought to agree.

som-snytt commented 1 year ago

Scala 2 installs a package _root_ in the root scope, which is why it balks at the user package of the same name.