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

Scala compiler crash when compiling a setting #1150

Closed
gkossakowski opened this issue Mar 5, 2014 · 7 comments
Closed

Scala compiler crash when compiling a setting #1150

gkossakowski opened this issue Mar 5, 2014 · 7 comments
Labels
Milestone

Comments

@gkossakowski
Copy link
Contributor

Consider the following build.sbt definition:

val touchIfChanged = taskKey[Unit]("")

touchIfChanged := { 
  val foo = (sourceDirectory in Compile).apply(base => base / "assets" ** "_*.styl").value.get
  ()
}

It crashes with sbt 0.13.2-{M1, M2} with:

  last tree to typer: This(anonymous class $anonfun)
              symbol: anonymous class $anonfun (flags: final <synthetic>)
   symbol definition: final class $anonfun extends AbstractFunction1[java.io.File,sbt.PathFinder] with Serializable
                 tpe: $94e2a720afd368c6099c.$anonfun.$anonfun.type
       symbol owners: anonymous class $anonfun -> value foo -> method apply -> anonymous class $anonfun -> method $sbtdef -> object $94e2a720afd368c6099c -> package <empty>
      context owners: value $outer -> anonymous class $anonfun -> value foo -> method apply -> anonymous class $anonfun -> method $sbtdef -> object $94e2a720afd368c6099c -> package <empty>

== Enclosing template or block ==

DefDef( // val $outer(): $94e2a720afd368c6099c.$anonfun.type
  <method> <synthetic> <stable> <expandedname>
  "$94e2a720afd368c6099c$$anonfun$$anonfun$$$outer"
  []
  List(Nil)
  <tpt> // tree.tpe=Any
  $anonfun.this."$outer " // private[this] val $outer: $94e2a720afd368c6099c.$anonfun.type, tree.tpe=$94e2a720afd368c6099c.$anonfun.type
)

== Expanded type of tree ==

ThisType(anonymous class $anonfun)

no-symbol does not have an owner
    at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)
    at scala.tools.nsc.Global.abort(Global.scala:254)
    at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3248)
    at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerSelect(ExplicitOuter.scala:266)
    at scala.tools.nsc.transform.ExplicitOuter$OuterPathTransformer.outerValue(ExplicitOuter.scala:244)
    at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:554)
    at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.transform(ExplicitOuter.scala:385)

It worked with sbt 0.13.1 so this a regression.

@gkossakowski gkossakowski added this to the 0.13.2 milestone Mar 5, 2014
@gkossakowski
Copy link
Contributor Author

@jsuereth: I assigned it to sbt 0.13.2 because it's a regression. Feel free to reconsider.

It's most likely a bug in macro code.

@jsuereth
Copy link
Member

jsuereth commented Mar 5, 2014

Yes. I'm still fighting the madness of fragmented settings :). Might have to delay the release one more week as I get a handle on things anyway, but this is still correctly assigned.

@gkossakowski
Copy link
Contributor Author

// cc @retronym who might have some insights

I haven't gotten around to dig deeper into it, yet.

@retronym
Copy link
Member

retronym commented Mar 7, 2014

I'm actually surprised that:

(sourceDirectory in Compile).apply(base => base / "assets" ** "_*.styl").value.get

worked beforehand.

@gkossakowski's suggestion to rewrite the build as:

val foo = ((sourceDirectory in Compile).value / "assets" ** "_*.styl").get

would be the typical way to express this.

I'll trace out the crash in any case.

retronym added a commit to retronym/sbt that referenced this issue Mar 7, 2014
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
@jsuereth
Copy link
Member

jsuereth commented Mar 8, 2014

@retronym @gkossakowski It seems another mole poped out of its hole, this one in our own build:

     while compiling: /home/jsuereth/projects/sbt/sbt/main/src/main/scala/sbt/Defaults.scala
        during phase: global=lambdalift, atPhase=constructors
     library version: version 2.10.3
    compiler version: version 2.10.3
  reconstructed args: -language:implicitConversions -language:postfixOps -language:higherKinds -language:existentials -feature -classpath /home/jsuereth/projects/sbt/sbt/main/target/classes:/home/jsuereth/projects/sbt/sbt/main/actions/target/classes:/home/jsuereth/projects/sbt/sbt/util/classpath/target/classes:/home/jsuereth/projects/sbt/sbt/launch/interface/target/classes:/home/jsuereth/projects/sbt/sbt/interface/target/interface-0.13.2-SNAPSHOT.jar:/home/jsuereth/projects/sbt/sbt/util/io/target/classes:/home/jsuereth/projects/sbt/sbt/util/control/target/classes:/home/jsuereth/projects/sbt/sbt/util/complete/target/classes:/home/jsuereth/projects/sbt/sbt/util/collection/target/classes:/home/jsuereth/projects/sbt/sbt/compile/api/target/classes:/home/jsuereth/projects/sbt/sbt/compile/integration/target/classes:/home/jsuereth/projects/sbt/sbt/compile/inc/target/classes:/home/jsuereth/projects/sbt/sbt/util/log/target/classes:/home/jsuereth/projects/sbt/sbt/util/process/target/classes:/home/jsuereth/projects/sbt/sbt/util/relation/target/classes:/home/jsuereth/projects/sbt/sbt/compile/target/classes:/home/jsuereth/projects/sbt/sbt/compile/persist/target/classes:/home/jsuereth/projects/sbt/sbt/util/classfile/target/classes:/home/jsuereth/projects/sbt/sbt/compile/ivy/target/classes:/home/jsuereth/projects/sbt/sbt/ivy/target/classes:/home/jsuereth/projects/sbt/sbt/util/cross/target/classes:/home/jsuereth/projects/sbt/sbt/run/target/classes:/home/jsuereth/projects/sbt/sbt/tasks/standard/target/classes:/home/jsuereth/projects/sbt/sbt/tasks/target/classes:/home/jsuereth/projects/sbt/sbt/cache/tracking/target/classes:/home/jsuereth/projects/sbt/sbt/cache/target/classes:/home/jsuereth/projects/sbt/sbt/testing/target/classes:/home/jsuereth/projects/sbt/sbt/testing/agent/target/classes:/home/jsuereth/projects/sbt/sbt/main/settings/target/classes:/home/jsuereth/projects/sbt/sbt/util/appmacro/target/classes:/home/jsuereth/projects/sbt/sbt/main/command/target/classes:/home/jsuereth/projects/sbt/sbt/util/logic/target/classes:/home/jsuereth/.sbt/boot/scala-2.10.3/lib/scala-compiler.jar:/home/jsuereth/.sbt/boot/scala-2.10.3/lib/scala-reflect.jar:/home/jsuereth/.ivy2/cache/jline/jline/jars/jline-2.11.jar:/home/jsuereth/.ivy2/cache/org.scala-tools.sbinary/sbinary_2.10/jars/sbinary_2.10-0.4.2.jar:/home/jsuereth/.ivy2/cache/org.apache.ivy/ivy/jars/ivy-2.3.0.jar:/home/jsuereth/.ivy2/cache/com.jcraft/jsch/jars/jsch-0.1.46.jar:/home/jsuereth/.ivy2/cache/org.scala-sbt/test-interface/jars/test-interface-1.0.jar -bootclasspath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/netx.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/plugin.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jfr.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/classes:/home/jsuereth/.sbt/boot/scala-2.10.3/lib/scala-library.jar -Xelide-below 0

  last tree to typer: term start
              symbol: variable start in class TaskTimings (flags: <mutable> <triedcooking> private[this])
   symbol definition: private[this] var start: Long
                 tpe: <notype>
       symbol owners: variable start -> class TaskTimings -> package sbt
      context owners: value x -> method apply -> anonymous class $anonfun$apply$18 -> method apply -> anonymous class $anonfun$testTasks$2 -> value testTasks -> object Defaults -> package sbt

== Enclosing template or block ==

DefDef( // final def apply(x: sbt.testing.Framework): Tuple2
  <method> final <triedcooking>
  "apply"
  []
  // 1 parameter list
  ValDef( // x: sbt.testing.Framework
    <param> <triedcooking>
    "x"
    <tpt> // tree.tpe=sbt.testing.Framework
    <empty>
  )
  <tpt> // tree.tpe=Tuple2
  Apply( // def <init>(_1: Object,_2: Object): Tuple2 in class Tuple2, tree.tpe=Tuple2
    new Tuple2."<init>" // def <init>(_1: Object,_2: Object): Tuple2 in class Tuple2, tree.tpe=(_1: Object, _2: Object)Tuple2
    // 2 arguments
    "f" // f: sbt.TestFramework, tree.tpe=sbt.TestFramework
    "x" // x: sbt.testing.Framework, tree.tpe=sbt.testing.Framework
  )
)

== Expanded type of tree ==

<notype>

unhandled exception while transforming Defaults.scala

I may need to revert this just to continue fixing other Ivy issues.

@jsuereth
Copy link
Member

jsuereth commented Mar 8, 2014

Appears to be this syntax:

loadedTestFrameworks := testFrameworks.value.flatMap(f => f.create(testLoader.value, streams.value.log).map( x => (f,x)).toIterable).toMap,

@jsuereth jsuereth reopened this Mar 8, 2014
@gkossakowski
Copy link
Contributor Author

@jsuereth: yes, please go ahead and revert. We'll investigate the problem shortly.

retronym added a commit to retronym/sbt that referenced this issue Mar 9, 2014
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
eed3si9n pushed a commit to eed3si9n/sbt that referenced this issue Mar 21, 2014
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
eed3si9n pushed a commit to eed3si9n/sbt that referenced this issue Mar 21, 2014
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
jvican pushed a commit to scalacenter/sbt that referenced this issue May 23, 2017
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
jvican pushed a commit to scalacenter/sbt that referenced this issue May 23, 2017
The qualifier of the `.value` call may contain `DefTree`s (e.g.
vals, defs) or `Function` trees. When we snip them out of the
tree and graft them into a new context, we must also call
`changeOwner`, so that the symbol owner structure and the tree
structure are coherent.

Failure to do so resulted in a crash in the compiler backend.

Fixes sbt#1150
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants