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

Class.getEnclosingClass is not the enclosing local anon class #8445

Closed
scabug opened this issue Mar 25, 2014 · 6 comments
Closed

Class.getEnclosingClass is not the enclosing local anon class #8445

scabug opened this issue Mar 25, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 25, 2014

Minimization using lemon juice for the invisible ink:

scala> class Y ; def y = { val yy = new Y { class Z ; def z = new Z().getClass }; yy.z }
warning: there were 1 feature warning(s); re-run with -feature for details
defined class Y
y: Class[_ <: AnyRef]

scala> y.getEnclosingClass.getName replaceAll ("\\Q$\\E", "%")
res3: String = %line4.%read%%iw%%iw%

or possibly more perspicaciously,

scala> object X { class Y; def y = new Y { class Z ; def z = classOf[Z] } } ; (X.y.getClass, X.y.z)
warning: there were 2 feature warning(s); re-run with -feature for details
defined object X
res0: (Class[?0], Class[_1.Z]) forSome { type ?0 <: X.Y; val _1: X.Y{type Z <: AnyRef; def z: Class[this.Z]} } = (class X$$anon$1,class X$$anon$1$Z)

scala> (res0._1.getEnclosingClass, res0._2.getEnclosingClass)
warning: there were 1 feature warning(s); re-run with -feature for details
res1: (Class[?0], Class[?0]) forSome { type ?0; type ?0 } = (class X$,class X$)

The encloser of Z should be X$$anon$1.

@scabug
Copy link
Author

scabug commented Mar 25, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8445?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.0-RC3
See #6622, #6759

@scabug
Copy link
Author

scabug commented Mar 25, 2014

@retronym said:
The comments of #6622 include a survey of the territory.

@scabug
Copy link
Author

scabug commented Mar 25, 2014

@retronym said:
Surely this was a perfect opportunity for :paste -raw to save on lemon juice.

@scabug
Copy link
Author

scabug commented Mar 25, 2014

@som-snytt said:
I tried :paste -cru. That's why we need :help paste.

@scabug
Copy link
Author

scabug commented Aug 5, 2014

@gkossakowski said:
The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

@scabug
Copy link
Author

scabug commented Sep 29, 2014

@lrytz said:
scala/scala#4011

@scabug scabug closed this as completed Sep 30, 2014
@scabug scabug added the backend label Apr 7, 2017
@scabug scabug added this to the 2.11.3 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants