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

@specialize vs. @inline: @specialize still wins #8247

Open
scabug opened this Issue Feb 6, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Feb 6, 2014

I'm not sure I understand what happened in #5005. It's clearly a bug, I opened it with a clear description of the bug, but it ended up being closed because it had become "confused". Okay, I will unconfuse things. Here is the same report again. One should not have to choose between @Specialize working and @inline working.

class C[U]() {
  @inline final def apply(x: U): U = x
}

class C2[@specialized(Boolean) U]() {
  @inline final def apply(x: U): U = x
}

class B {
  private val cNormal = new C[Boolean]()
  private val cSpec   = new C2[Boolean]()
  
  final def m1 = cNormal(true)
  final def m2 = cSpec(true)
  // ./a.scala:14: warning: Could not inline required method apply$mcZ$sp because it can be overridden.
  //   final def m2 = cSpec(true)
  //                       ^
  // one warning found

  // however, here it inlines
  cNormal(true)
  cSpec(true)
}

To answer the question of what it would take to be considered fixed - it's fixed with respect to this ticket when the bytecode of methods m1 and m2 both is constant true.

@scabug

This comment has been minimized.

Copy link

scabug commented Feb 6, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8247?orig=1
Reporter: @paulp
Affected Versions: 2.11.0
See #5005

@scabug scabug added this to the Backlog milestone Apr 7, 2017

@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Mar 2, 2018

can someone verify if this is still an issue in Scala 2.12.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment