Skip to content
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

Implicit conversions can add extension type members #19888

Closed
lihaoyi opened this issue Mar 6, 2024 · 0 comments · Fixed by #19934
Closed

Implicit conversions can add extension type members #19888

lihaoyi opened this issue Mar 6, 2024 · 0 comments · Fixed by #19934
Assignees
Labels
area:implicits related to implicits itype:bug
Milestone

Comments

@lihaoyi
Copy link
Contributor

lihaoyi commented Mar 6, 2024

Compiler version

3.4.0

Minimized code

object Main{
  object Foo
  object Bar{ type Qux = Unit }


  implicit def conv(f: Foo.type): Bar.type = Bar

  def B: Bar.type = Bar

  def main(args: Array[String]): Unit = {
    val x: Foo.Qux = null
    val y: B.Qux = null
    println(x)
    println(y)
  }  
}

Output

null
null

Expectation

I would expect A.Qux to be a compilation error, because A does not have a member type Qux, without the implicit conversion.

I would expect B.Qux to be a compilation error, because B is not a stable path prefix for the B.Qux path dependent type

The equivalent code is a compilation error in Scala 2.x. It definitely seems weird that implicit conversions and other non-stable methods can be used in the path dependent type's path prefix!

TBH not sure if this is bug or feature, but @odersky mentioned it might be a bug, so filing it here for posterity.

@lihaoyi lihaoyi added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 6, 2024
@Gedochao Gedochao added area:implicits related to implicits and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 6, 2024
@odersky odersky self-assigned this Mar 6, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 12, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:implicits related to implicits itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants