Closed
Description
Compiler version
3.3.3
, 3.4.2
, 3.5.0-RC7
, 3.5.1-RC1
Preface
I'm not sure if this is a bug or works as intended. The same code compiles in Scala 2 and I don't know why it shouldn't in Scala 3 - but I might be just unaware of a particular limitation/restriction introduced in dotty.
Minimized code
(https://scastie.scala-lang.org/a2YCoAw8TOyOXi2Q7vl5Gg)
case class Table(owner: Owner.Id)
case class Owner(owner: Owner.Id) // type Id is not a member of object Playground.Owner
trait Typed[Tag] {
type Id = String
}
object Owner extends Typed[Owner] {
//type Id = String
}
Output
(from scastie)
type Id is not a member of object Playground.Owner
Expectation
Expectation is for this code to compile.
Observations:
- this code compiles in Scala 2 (https://scastie.scala-lang.org/VgS8ZtZZS1uI10SV6DbOGQ)
- if only one of the case classes references the
Owner.Id
- it compiles (https://scastie.scala-lang.org/X4cRDtzcTUa0ZrIBkowU6w) - if
type Id
is defined directly in the object (the commented out line) - it compiles (https://scastie.scala-lang.org/noCBIv1TQUGeNBuSHoFdKQ) - if the type parameter for
Typed
is not theOwner
class - it compiles (https://scastie.scala-lang.org/0Y0hTN0oQtuQjT7YVBfpVg)