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
compiler crash with -optimize and separate compilation #9121
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9121?orig=1
|
Gia Bảo (giabao) said: // Implicits.scala
import rx.Observable
import rx.functions.Func1
import scala.language.implicitConversions
object Implicits {
implicit class ScalaObservable[T](val underlying: Observable[T]) extends AnyVal {
//if remove `@inline` annotation then test will success
@inline def scMap[R](f: T => R): Observable[R] = underlying.map[R](f.toRx)
//if change `f.toRx` to `new SFunc1(f)` then test will success
//@inline def scMap[R](f: T => R): Observable[R] = underlying.map[R](new SFunc1(f))
}
final class SFunc1[T1, R](f: T1 => R) extends Func1[T1, R] {
def call(t1: T1): R = f(t1)
}
implicit class RichFunction1[T1, R](val f: T1 => R) extends AnyVal {
def toRx = new SFunc1(f)
}
} // LogView.scala
import com.sandinh.couchbase.document.JsDocument
import play.api.libs.json.{JsValue, Json}
import rx.Observable
//if we `import com.sandinh.rx.Implicits._` instead of `import Implicits._`
//then both sbt clean compile & increment compile will be failed
import com.sandinh.rx.Implicits._
//if we `import Implicits._` instead of `import com.sandinh.rx.Implicits._`
//then clean compile will success, but after that, if we change this file
// ex, by adding/ deleting `private` modifier from `def row2Obs`,
// then run increment compile => failed!
//import Implicits._
object LogView {
private def row2Obs(doc: Observable[JsDocument]): Observable[JsValue] =
doc.scMap(d => Json.obj(d.id -> d.content))
} // build.sbt}
name := "test"
version := "1.0"
//tested (fail) with both scala 2.11.5 & 2.11.6-20150127.023613-7
//resolvers += Resolver.sonatypeRepo("snapshots")
//scalaVersion := "2.11.6-SNAPSHOT"
scalaVersion := "2.11.5"
scalacOptions ++= Seq("-encoding", "UTF-8"
,"-optimise" //only fail with -optimise option
// ,"-Ybackend:GenBCode" //tested (fail) with both GenASM & GenBCode backends
)
libraryDependencies += "com.sandinh" %% "couchbase-scala" % "6.1.0-SNAPSHOT"
//tested (fail) with & without this setting:
libraryDependencies <+= scalaVersion(v => "org.scala-lang" % "scala-reflect" % v) |
Gia Bảo (giabao) said (edited on Jan 30, 2015 11:56:12 AM UTC):
|
Gia Bảo (giabao) said:
|
@retronym said (edited by @lrytz on Feb 5, 2015 8:17:13 PM UTC): tail $(find test/files/run -type f | grep t9121)
==> test/files/run/t9121/A_1.scala <==
package p1
object Implicits {
class ScalaObservable(val underlying: Any) extends AnyVal {
//if remove `@inline` annotation then test will success
@inline def scMap[R](f: String): Any = f.toRx
}
implicit class RichFunction1[T1, R](val f: String) extends AnyVal {
def toRx: Any = ""
}
}
==> test/files/run/t9121/B_2.scala <==
import p1.Implicits._
object Test {
def main(args: Array[String]): Unit = {
new ScalaObservable("").scMap("")
}
}
==> test/files/run/t9121.flags <==
-optimize The crash manifests when the inliner reconsitutes the symbol/type information from A_1 when separately compiling B_2. It seems we end up with a LOAD_FIELD() ICode instruction that refers to a method symbol, rather than a field symbol. I haven't managed to figure out why this is happening, though. |
@retronym said: |
@lrytz said: |
@retronym said:
That gets as far as a new crash:
The problem is that the module and the factory method from the implicit class have the same name. |
@lrytz said: ICodeReader is loading the bytecode of Once the The assertion failure that Jason (and me) observed in the backend is then due to the fact that this JAVA marked module symbol is used: if you call I'm not sure how much of that we can safely change before 2.11.6. |
@dragos said:
|
@lrytz said: |
@lrytz said: |
see https://github.com/giabao/scala-bug
sorry, I don't know exactly what Component the bug is related to.
The text was updated successfully, but these errors were encountered: