-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Multi output problem with delambdafied compilation #4809
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
Multi output problem with delambdafied compilation #4809
Conversation
The CLA checker is off. @wpopielarski has signed the CLA according to my checks :) |
/synch |
@@ -25,6 +25,9 @@ trait BytecodeWriters { | |||
def outputDirectory(sym: Symbol): AbstractFile = | |||
settings.outputDirs outputDirFor enteringFlatten(sym.sourceFile) | |||
|
|||
def outputDirectory(cunitSource: scala.reflect.internal.util.SourceFile): AbstractFile = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the fully qualified name, SourceFile
is just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done
This change also needs to be applied to this method in
I'm happy enough with the defensive/conservative approach in 2.11.x. For 2.12, I think we can just simplify this to always base this on the compilation unit, rather than than I agree with @dragos : we should not emit compiler warnings here. You can use It is probably a good idea to set val lambdaClass = pkg newClassSymbol(name, originalFunction.pos, FINAL | SYNTHETIC) addAnnotation SerialVersionUIDAnnotation And I think both test cases would work. |
I know this code predates your patch, but I'm not a fan of catching |
I'd also like to see a test case for this change. |
Thanks guys for advices. I implement them with pleasure :). 2015-10-29 2:23 GMT+01:00 Jason Zaugg notifications@github.com:
|
@retronym in Delambdafy.scala I wanted to set source file with |
User code compilation with -Ybackend:GenBCode -Ydelambdafy:method fails for projects with multiple output directories. The problem has its root in a fact that some `lambdaClass` symbols the `associatedFile` field is not set. It can be done in Delambdafy.scala (`makeAnonymousClass` method) and is working for following lambda examples: {{{ package acme object Delambdafy { type -->[D, I] = PartialFunction[D, I] def main(args: Array[String]): Unit = { val result = List(1, 2, 4).map { a => val list = List("1", "2", "3").map { _ + "test" } list.find { _ == a.toString + "test" } } lazy val _foo = foo(result) { case x::xs if x isDefined => x.get.length case _ => 0 } lazy val bar: Int => Int = { case 2 => 13 case _ => val v = List(1).map(_ + 42).head v + 1 } } def foo(b: List[Option[String]])(a: List[Option[String]] => Int): Int = a(b) } }}} but is NOT working for following lambda: {{{ package acme object Delambdafy { type -->[D, I] = PartialFunction[D, I] def main(args: Array[String]): Unit = { lazy val _baz = baz { case 1 => val local = List(1).map(_ + 1) local.head } } def baz[T](f: Any --> Any): Any => Any = f } }}} so that's why source of compilation unit is used to determine output directory in case when source file is not found for symbol.
This source is then used to figure out output folder for compilation product.
999280e
to
9688625
Compare
LGTM. Thanks for adding the test case. |
Multi output problem with delambdafied compilation
User code compilation with -Ybackend:GenBCode -Ydelambdafy:method
fails for projects with multiple output directories.
The problem has its root in a fact that some
lambdaClass
symbolsthe
associatedFile
field is not set. It can be done in Delambdafy.scala(
makeAnonymousClass
method) and is working for following lambdaexamples:
but is NOT working for following lambda:
so that's why source of compilation unit is used to determine output
directory in case when source file is not found for symbol.