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

@varargs causes all inner classes to fail to compile on 2.9.2 with "trying to access this of another class" #6953

Closed
scabug opened this issue Jan 9, 2013 · 3 comments

Comments

@scabug
Copy link

scabug commented Jan 9, 2013

import scala.annotation.varargs

class Broken {
   @varargs def method(ss: String*): Unit = ()
   class Inner { }
}

causes:

java.lang.AssertionError: assertion failed: Trying to access the this of another class: tree.symbol = class $read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$Broken, ctx.clazz.symbol = class $read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$Broken$Inner compilation unit:<console>
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:962)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1175)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:921)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:114)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:76)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:136)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:88)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$gen$1.apply(GenICode.scala:69)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:76)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:69)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:79)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:65)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:61)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
	at scala.collection.Iterator$class.foreach(Iterator.scala:772)
	at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:318)
	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
	at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:54)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)

but this code:

class Works {
   def method(ss: String*): Unit = ()
   class Inner { }
}

works fine.

This is the first time I've filed a bug on the Scala JIRA, so sorry if I mucked up the labels or what have you.

@scabug
Copy link
Author

scabug commented Jan 9, 2013

Imported From: https://issues.scala-lang.org/browse/SI-6953?orig=1
Reporter: Ross Mellgren (rmellgren)
Affected Versions: 2.9.2
See #5125

@scabug
Copy link
Author

scabug commented Jan 9, 2013

Ross Mellgren (rmellgren) said:
Oh, as an additional note this seems to prevent any inner classes from being used, even synthetic ones such as function closures.

@scabug
Copy link
Author

scabug commented Jul 23, 2014

@gourlaysama said:
This was fixed in 2.10.0-M4 by the fix for (the very similar) SI-5125.

(It was surprisingly easy to find the right commit: scala-hash + git bisect = commit finding awesomeness.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant