Skip to content

a type defined in a trait is "not found" in an object that extends the trait (under certain circumstances) #21360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yurique opened this issue Aug 9, 2024 · 1 comment · Fixed by #21591

Comments

@yurique
Copy link

yurique commented Aug 9, 2024

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:

@yurique yurique added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 9, 2024
@yurique yurique changed the title type defined in a trait "not found" in an object extending the trait under certain circumstances type defined in a trait is "not found" in an object extending the trait under certain circumstances Aug 9, 2024
@yurique yurique changed the title type defined in a trait is "not found" in an object extending the trait under certain circumstances type defined in a trait is "not found" in an object that extends the trait (under certain circumstances) Aug 9, 2024
@yurique yurique changed the title type defined in a trait is "not found" in an object that extends the trait (under certain circumstances) a type defined in a trait is "not found" in an object that extends the trait (under certain circumstances) Aug 9, 2024
@NyuB
Copy link

NyuB commented Aug 11, 2024

Played a bit and found some more details, hope it can help to understand/debug:

  • The bug is not related to the object being a 'companion object' of Owner, the name does not matter (the following does not compile)
case class A(owner: Obj.Id)

case class B(owner: Obj.Id)

trait Typed[Tag] {
  type Id = String
}

object Obj extends Typed[B]
case class A(owner: Obj.Id)

case class B(owner: Obj.Id)

case class C(owner: Obj.Id)

trait Typed[Tag] {
  type Id = String
}

object Obj extends Typed[B]
case class A(owner: Obj.Id)

case class B(notAndObjId: String)

case class C(owner: Obj.Id)

trait Typed[Tag] {
  type Id = String
}

object Obj extends Typed[B]

@Gedochao Gedochao added area:typer regression:scala2 and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 19, 2024
odersky added a commit that referenced this issue Sep 14, 2024
Closes #21360 

@dwijnand This might have been fixed by your recently merged changes to
constructor completion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants