Scala Programming Language
  1. Scala Programming Language
  2. SI-6301

Adding @specialized annotation crashes the compiler.

    Details

      Description

      Unfortunately I haven't been able to minimize the problem from my encounter with it in the wild.

      Steps to reproduce:

      hg clone https://bitbucket.org/scottmorrison/toolkit
      hg update -r f7cf0edfbd7c
      ./sbt compile
      # works fine!
      hg update -r 16af6ffa2750
      ./sbt compile
      # crashes the compiler!
      

      The difference is a single specialization annotation, per <https://bitbucket.org/scottmorrison/toolkit/compare/16af6ffa2750..f7cf0edfbd7c>.

      The compiler error message is

      [error] uncaught exception during compilation: scala.MatchError
      [error] {file:/Users/scott/projects/toolkit/}toolkit-algebra/compile:compile: scala.MatchError: (xs: collection.GenIterable)Int <and> (x0: Int, x1: Seq)Int <and> (x: Int, y: Int)Int (of class scala.reflect.internal.Types$OverloadedType)
      

      and the output from `last` in sbt is

      [error] uncaught exception during compilation: scala.MatchError
      scala.MatchError: (xs: collection.GenIterable)Int <and> (x0: Int, x1: Seq)Int <and> (x: Int, y: Int)Int (of class scala.reflect.internal.Types$OverloadedType)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transformApplyDynamic(CleanUp.scala:444)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:525)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.collection.immutable.List.loop$1(List.scala:164)
      	at scala.collection.immutable.List.mapConserve(List.scala:180)
      	at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:659)
      	at scala.reflect.internal.Trees$class.itransform(Trees.scala:1160)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:692)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.collection.immutable.List.loop$1(List.scala:164)
      	at scala.collection.immutable.List.mapConserve(List.scala:180)
      	at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:659)
      	at scala.reflect.internal.Trees$class.itransform(Trees.scala:1160)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:692)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1176)
      	at scala.reflect.internal.Trees$$anonfun$itransform$2.apply(Trees.scala:1174)
      	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
      	at scala.reflect.internal.Trees$class.itransform(Trees.scala:1173)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:692)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformTrees$1.apply(Trees.scala:659)
      	at scala.collection.immutable.List.loop$1(List.scala:164)
      	at scala.collection.immutable.List.mapConserve(List.scala:180)
      	at scala.reflect.api.Trees$Transformer.transformTrees(Trees.scala:659)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.scala$tools$nsc$transform$CleanUp$CleanUpTransformer$$transformTemplate(CleanUp.scala:54)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:538)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:661)
      	at scala.reflect.internal.Trees$$anonfun$itransform$4.apply(Trees.scala:1221)
      	at scala.reflect.internal.Trees$$anonfun$itransform$4.apply(Trees.scala:1220)
      	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
      	at scala.reflect.internal.Trees$class.itransform(Trees.scala:1219)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:692)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:677)
      	at scala.reflect.api.Trees$Transformer$$anonfun$transformStats$1.apply(Trees.scala:675)
      	at scala.collection.immutable.List.loop$1(List.scala:164)
      	at scala.collection.immutable.List.mapConserve(List.scala:180)
      	at scala.reflect.api.Trees$Transformer.transformStats(Trees.scala:675)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transformStats(CleanUp.scala:793)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transformStats(CleanUp.scala:25)
      	at scala.reflect.internal.Trees$$anonfun$itransform$7.apply(Trees.scala:1239)
      	at scala.reflect.internal.Trees$$anonfun$itransform$7.apply(Trees.scala:1239)
      	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
      	at scala.reflect.internal.Trees$class.itransform(Trees.scala:1238)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.internal.SymbolTable.itransform(SymbolTable.scala:12)
      	at scala.reflect.api.Trees$Transformer.transform(Trees.scala:656)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:692)
      	at scala.tools.nsc.transform.CleanUp$CleanUpTransformer.transform(CleanUp.scala:25)
      	at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:227)
      	at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
      	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:455)
      	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:422)
      	at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:422)
      	at scala.collection.Iterator$class.foreach(Iterator.scala:726)
      	at scala.collection.AbstractIterator.foreach(Iterator.scala:1155)
      	at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:422)
      	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1566)
      	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1540)
      	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1536)
      	at scala.tools.nsc.Global$Run.compile(Global.scala:1646)
      	at xsbt.CompilerInterface.run(CompilerInterface.scala:87)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:57)
      	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:29)
      	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:25)
      	at sbt.AggressiveCompile$$anonfun$5.compileScala$1(AggressiveCompile.scala:67)
      	at sbt.AggressiveCompile$$anonfun$5.apply(AggressiveCompile.scala:79)
      	at sbt.AggressiveCompile$$anonfun$5.apply(AggressiveCompile.scala:57)
      	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:21)
      	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:19)
      	at sbt.inc.Incremental$.cycle(Incremental.scala:33)
      	at sbt.inc.Incremental$.compile(Incremental.scala:20)
      	at sbt.inc.IncrementalCompile$.apply(Compile.scala:17)
      	at sbt.AggressiveCompile.compile2(AggressiveCompile.scala:87)
      	at sbt.AggressiveCompile.compile1(AggressiveCompile.scala:41)
      	at sbt.AggressiveCompile.apply(AggressiveCompile.scala:28)
      	at sbt.Compiler$.apply(Compiler.scala:107)
      	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:479)
      	at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:479)
      	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:473)
      	at sbt.Scoped$$anonfun$hf2$1.apply(Structure.scala:473)
      	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:41)
      	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$11.apply(Structure.scala:295)
      	at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$11.apply(Structure.scala:295)
      	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
      	at sbt.std.Transform$$anon$5.work(System.scala:67)
      	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:221)
      	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:221)
      	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
      	at sbt.Execute.work(Execute.scala:227)
      	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:221)
      	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:221)
      	at sbt.CompletionService$$anon$1$$anon$2.call(CompletionService.scala:26)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      	at java.lang.Thread.run(Thread.java:680)
      [error] {file:/Users/scott/projects/toolkit/}toolkit-algebra/compile:compile: scala.MatchError: (xs: collection.GenIterable)Int <and> (x0: Int, x1: Seq)Int <and> (x: Int, y: Int)Int (of class scala.reflect.internal.Types$OverloadedType)
      

        Issue Links

          Activity

          Hide
          Aleksandar Prokopec added a comment -

          A minimized test case would be helpful.

          Show
          Aleksandar Prokopec added a comment - A minimized test case would be helpful.
          Hide
          Scott Morrison added a comment -

          I did spend a while investigating, but needed to triage my time spent on this, and report as best I could. I'm sorry it's still a monster.

          Show
          Scott Morrison added a comment - I did spend a while investigating, but needed to triage my time spent on this, and report as best I could. I'm sorry it's still a monster.
          Hide
          Paul Phillips added a comment -

          That's OK, I can see what it is. I can't exactly fix it right now, but I can do this:

          Select received overloaded type during explicitouter, but typer is over.
          We are likely doomed to crash in the backend.
          modP.add$mcI$sp has these overloads:
            def add$mcI$sp(xs: scala.collection.GenIterable[Int]): Int
            def add$mcI$sp(x0: Int,x1: Seq[Int]): Int
            def add$mcI$sp(x: Int,y: Int): Int
          
          [...]
          [warn] /Users/paulp/Desktop/toolkit/algebra/src/main/scala/net/tqft/toolkit/algebra/grouptheory/FiniteGroup.scala:223: Overloaded type reached the backend! This is a bug in scalac.
          [warn]      Symbol: value add$mcI$sp
          [warn]   Overloads: (xs: collection.GenIterable)Int <and> (x0: Int, x1: Seq)Int <and> (x: Int, y: Int)Int
          [warn]   Arguments: List(Object)
          [warn]     def mu(i: Int)(j: Int)(s: Int) = modP.quotient(modP.add(for (n <- 0 until exponent) yield modP.multiply(chi(i)(exponentiationOnConjugacyClasses(n)(j)), zpower((-s * n) mod exponent))), exponent)
          [warn]                                                            ^
          [warn] Only one overload has the right arity, proceeding with overload List((xs: collection.GenIterable)Int)
          [warn] there were 7 deprecation warnings; re-run with -deprecation for details
          [warn] there were 50 feature warnings; re-run with -feature for details
          [warn] four warnings found
          [success] Total time: 38 s, completed Aug 31, 2012 8:32:58 AM
          
          Show
          Paul Phillips added a comment - That's OK, I can see what it is. I can't exactly fix it right now, but I can do this: Select received overloaded type during explicitouter, but typer is over. We are likely doomed to crash in the backend. modP.add$mcI$sp has these overloads: def add$mcI$sp(xs: scala.collection.GenIterable[Int]): Int def add$mcI$sp(x0: Int,x1: Seq[Int]): Int def add$mcI$sp(x: Int,y: Int): Int [...] [warn] /Users/paulp/Desktop/toolkit/algebra/src/main/scala/net/tqft/toolkit/algebra/grouptheory/FiniteGroup.scala:223: Overloaded type reached the backend! This is a bug in scalac. [warn] Symbol: value add$mcI$sp [warn] Overloads: (xs: collection.GenIterable)Int <and> (x0: Int, x1: Seq)Int <and> (x: Int, y: Int)Int [warn] Arguments: List(Object) [warn] def mu(i: Int)(j: Int)(s: Int) = modP.quotient(modP.add(for (n <- 0 until exponent) yield modP.multiply(chi(i)(exponentiationOnConjugacyClasses(n)(j)), zpower((-s * n) mod exponent))), exponent) [warn] ^ [warn] Only one overload has the right arity, proceeding with overload List((xs: collection.GenIterable)Int) [warn] there were 7 deprecation warnings; re-run with -deprecation for details [warn] there were 50 feature warnings; re-run with -feature for details [warn] four warnings found [success] Total time: 38 s, completed Aug 31, 2012 8:32:58 AM
          Hide
          Paul Phillips added a comment -

          I lied, I fixed it.

          Show
          Paul Phillips added a comment - I lied, I fixed it.
          Hide
          Paul Phillips added a comment -
          Show
          Paul Phillips added a comment - The fix is amongst https://github.com/scala/scala/pull/1226 .
          Hide
          Jason Zaugg added a comment -
          Show
          Jason Zaugg added a comment - Backport https://github.com/scala/scala/pull/2006

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Scott Morrison
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development