Skip to content

Specialization's duplicator loses annotations #7579

Description

@scabug
$ cat Z.scala 
object Test {
  class myAnnotation extends scala.annotation.StaticAnnotation
  def dontForgetTheAnnotation_![@specialized(Int) X](x: X) = {
    @myAnnotation val y = 3
  }
}

$ scalac Z.scala -Xprint:spec
[[syntax trees at end of                specialize]] // Z.scala
package <empty> {
  object Test extends Object {
    ...
    def dontForgetTheAnnotation_![@specialized(scala.Int) X >: Nothing <: Any](x: X): Unit = {
      @Test.myAnnotation val y: Int = 3;
      ()
    };
    <specialized> def dontForgetTheAnnotation_!$mIc$sp(x: Int): Unit = {
      val y: Int = 3; // @Test.annotation was lost during duplication
      ()
    }
  }
}

This prevents a full fix for #7344.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions