-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Suppose we have the case class:
case class MyExample(x: Int)
We could use it to pattern match as follows:
def example {
val ex: Array[MyExample] = new Array[MyExample](10)
optimize {
for (MyExample(x) <- ex) {
println(x)
}
}
}
The following syntactic modification of the above code also works without problem:
def example: Unit = { // This is the only line that has changed
val ex: Array[MyExample] = new Array[MyExample](10)
optimize {
for (MyExample(x) <- ex) {
println(x)
}
}
}
However, the following syntactic modification causes the compiler to crash big time!
def example = { // Again, this is the only line that has changed
val ex: Array[MyExample] = new Array[MyExample](10)
optimize {
for (MyExample(x) <- ex) {
println(x)
}
}
}
When I try to compile a class that contains the last method above, it bombs out with the following internal exception and stack trace:
scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving method example
at scala.reflect.internal.Symbols$Symbol$$anonfun$info$3.apply(Symbols.scala:1418)
at scala.reflect.internal.Symbols$Symbol$$anonfun$info$3.apply(Symbols.scala:1416)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.reflect.internal.Symbols$Symbol.lock(Symbols.scala:532)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1416)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:174)
at scalaxy.streams.HacksAndWorkarounds$$anon$1$$anonfun$traverse$2.apply(HacksAndWorkarounds.scala:31)
at scalaxy.streams.HacksAndWorkarounds$$anon$1$$anonfun$traverse$2.apply(HacksAndWorkarounds.scala:26)
at scala.Option$WithFilter.foreach(Option.scala:208)
at scalaxy.streams.HacksAndWorkarounds$$anon$1.traverse(HacksAndWorkarounds.scala:26)
at scala.reflect.api.Trees$Traverser.traverseTrees(Trees.scala:2484)
at scala.reflect.internal.Trees$class.traverseComponents$1(Trees.scala:1277)
at scala.reflect.internal.Trees$class.itraverse(Trees.scala:1323)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.api.Trees$Traverser.traverse(Trees.scala:2475)
at scalaxy.streams.HacksAndWorkarounds$$anon$1.traverse(HacksAndWorkarounds.scala:43)
at scala.reflect.api.Trees$Traverser.traversePattern(Trees.scala:2476)
at scala.reflect.internal.Trees$class.traverseComponents$1(Trees.scala:1230)
at scala.reflect.internal.Trees$class.itraverse(Trees.scala:1323)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.api.Trees$Traverser.traverse(Trees.scala:2475)
at scalaxy.streams.HacksAndWorkarounds$$anon$1.traverse(HacksAndWorkarounds.scala:43)
at scala.reflect.api.Trees$Traverser.traverseTrees(Trees.scala:2484)
at scala.reflect.api.Trees$Traverser.traverseCases(Trees.scala:2487)
at scala.reflect.internal.Trees$class.traverseComponents$1(Trees.scala:1258)
at scala.reflect.internal.Trees$class.itraverse(Trees.scala:1323)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
at scala.reflect.api.Trees$Traverser.traverse(Trees.scala:2475)
at scalaxy.streams.HacksAndWorkarounds$$anon$1.traverse(HacksAndWorkarounds.scala:43)
...
Lastly, on a general note, many thanks for all that you have been doing with Scalaxy/Streams recently. It has been of tremendous value in my current project!
Metadata
Metadata
Assignees
Labels
No labels