Skip to content

export doesn't work inside anonymous classes #7920

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
soronpo opened this issue Jan 8, 2020 · 2 comments · Fixed by #9537
Closed

export doesn't work inside anonymous classes #7920

soronpo opened this issue Jan 8, 2020 · 2 comments · Fixed by #9537
Assignees

Comments

@soronpo
Copy link
Contributor

soronpo commented Jan 8, 2020

minimized code

class Bar {val glass : Int = 0}
class Foo(val bar : Bar) 
val f = new Foo(new Bar) {
  export bar._
}
val fGlass = f.glass //error: value glass is not a member of Foo

expectation

This code should compile. I see no reason why export shouldn't work in anonymous classes.

@odersky
Copy link
Contributor

odersky commented Jan 8, 2020

This has nothing to do with exports. If you replace the export with val glass = bar.glass, it fails as well. See
https://contributors.scala-lang.org/t/better-type-inference-for-scala-send-us-your-problematic-cases/2410/73 for background.

I believe we should implement the Structural idea that @smarter proposed in that thread, though.

@soronpo
Copy link
Contributor Author

soronpo commented Aug 12, 2020

Fixed in #9201

class Bar {val glass : Int = 0}
class Foo(val bar : Bar) extends scala.reflect.Selectable
val f = new Foo(new Bar) {
  export bar._
}
val fGlass = f.glass

https://scastie.scala-lang.org/IrMU1eYaSBOW33nPbo2JOQ

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