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

generation incorrect code (java.lang.InternalError) when using reflection over locally-creared traits inside named parameters arguments #8953

Closed
scabug opened this issue Nov 3, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Nov 3, 2014

next code (attached in archive to ticked and available from https://github.com/rssh/scala-gopher/blob/scala-2.11.4-internal-error-localized/src/main/scala/gopherCompilerIssue/Test.scala )

package gopherCompilerIssue

trait TBase
{

class InPortA
{
var v: A = a
}

object InPort
{
def applyA:InPort[A] = new InPort(a)
}

import scala.reflect._
import scala.reflect.runtime.{universe=>ru}

def retrieveVals1T:ru.TypeTag: List[T] =
{
val mirror = ru.runtimeMirror(this.getClass.getClassLoader)
val im = mirror.reflect(o);
val termMembers = im.symbol.typeSignature.members.filter(.isTerm).map(.asTerm)
val retval = (termMembers.
filter ( x => x.typeSignature <:< ru.typeOf[T] && x.isVal).
map ((x:ru.TermSymbol) => im.reflectField(x).get.asInstanceOf[T])
).toList
retval
}

def retrievePorts = retrieveVals1InPort[_]

def recoverFactory: ()=>TBase

}

trait Bingo extends TBase
{
val inX = InPortInt
}
class Suite
{

test("A") {
val bingo = { def factory(): Bingo = new Bingo {
def recoverFactory = factory
}
factory()
}

 bingo.retrievePorts

}

def test(name:String)(fun: => Unit):Unit =
fun

}
object Main
{

def main(args:Array[String]):Unit = {
val s = new Suite();
}

}

produce internal error when run .[info] Running gopherCompilerIssue.Main
[error] (run-main) java.lang.InternalError: Enclosing method not found
java.lang.InternalError: Enclosing method not found
at java.lang.Class.getEnclosingMethod(Class.java:1052)
at scala.reflect.runtime.ReflectionUtils$EnclosedInMethod$$anonfun$$lessinit$greater$1.apply(ReflectionUtils.scala:98)
at scala.reflect.runtime.ReflectionUtils$EnclosedInMethod$$anonfun$$lessinit$greater$1.apply(ReflectionUtils.scala:98)
at scala.reflect.runtime.ReflectionUtils$EnclosedIn.unapply(ReflectionUtils.scala:95)
at scala.reflect.runtime.JavaMirrors$JavaMirror.sOwner(JavaMirrors.scala:842)
at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$classToScala1(JavaMirrors.scala:982)
at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:975)
at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$classToScala$1.apply(JavaMirrors.scala:975)
at scala.reflect.runtime.JavaMirrors$JavaMirror$$anonfun$toScala$1.apply(JavaMirrors.scala:97)
at scala.reflect.runtime.TwoWayCaches$TwoWayCache$$anonfun$toScala$1.apply(TwoWayCaches.scala:39)
at scala.reflect.runtime.Gil$class.gilSynchronized(Gil.scala:19)
at scala.reflect.runtime.JavaUniverse.gilSynchronized(JavaUniverse.scala:16)

@scabug
Copy link
Author

scabug commented Nov 3, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8953?orig=1
Reporter: ruslan shevchenko (rssh)
Affected Versions: 2.11.4
See #9105
Attachments:

@scabug
Copy link
Author

scabug commented Apr 28, 2015

@retronym said:
This might have been fixed in #9105. [~rssh] Could you please retest against 2.11.6?

@scabug
Copy link
Author

scabug commented Mar 10, 2016

ruslan shevchenko (rssh) said:
Can confirm that fixed in 2.11.8

@scabug scabug closed this as completed Mar 10, 2016
@scabug scabug added the backend label Apr 7, 2017
@scabug scabug added this to the 2.11.8 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