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

Cannot inline methods in nested objects in other projects #8524

Closed
scabug opened this issue Apr 22, 2014 · 2 comments
Closed

Cannot inline methods in nested objects in other projects #8524

scabug opened this issue Apr 22, 2014 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 22, 2014

Create the three files:

// library/Library.scala
package library
object Library {
  @inline def pleaseInlineMe() = 0
  object Nested {
    @inline def pleaseInlineMe() = 0
  }
}
// Application.scala
object Application {
  def main(arguments: Array[String]): Unit = {
    // No warning here
    println(library.Library.pleaseInlineMe())

    // Could not inline required method pleaseInlineMe because bytecode unavailable.
    println(library.Library.Nested.pleaseInlineMe())
  }
}
// build.sbt
lazy val library = Project("library", file("library"))

lazy val application = Project("application", file(".")).dependsOn(library)

scalacOptions += "-Yinline-warnings"

scalacOptions += "-optimise"

I expect both methods are inlined, but the one in the nested object isn't.

$ sbt compile
[info] Loading global plugins from C:\Users\user\.sbt\0.13\plugins
[info] Set current project to application (in build file:/D:/cygwin/home/user/Documents/inline-nested-object/)
[info] Compiling 1 Scala source to D:\cygwin\home\user\Documents\inline-nested-object\library\target\scala-2.10\classes...
[info] Compiling 1 Scala source to D:\cygwin\home\user\Documents\inline-nested-object\target\scala-2.10\classes...
[warn] D:\cygwin\home\user\Documents\inline-nested-object\Application.scala:8: Could not inline required method pleaseInlineMe because bytecode unavailable.
[warn]     println(library.Library.Nested.pleaseInlineMe())
[warn]                                                  ^
[warn] one warning found
[success] Total time: 4 s, completed 2014-4-22 16:13:10
@scabug
Copy link
Author

scabug commented Apr 22, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8524?orig=1
Reporter: @Atry
Affected Versions: 2.10.4, 2.11.0

@scabug
Copy link
Author

scabug commented Feb 3, 2016

@lrytz said:
fixed in new optimizer, test case added in scala/scala#4920

@scabug scabug closed this as completed Feb 3, 2016
@scabug scabug added this to the 2.12.0-M4 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants