Scala Programming Language
  1. Scala Programming Language
  2. SI-7579

Specialization's duplicator loses annotations

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.2-RC2
    • Fix Version/s: None
    • Component/s: Specialization
    • Labels:

      Description

      $ 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 SI-7344.

        Activity

        Hide
        Vlad Ureche added a comment -

        Note to self: don't forget to enable the test case for SI-7344 when this is fixed.

        Show
        Vlad Ureche added a comment - Note to self: don't forget to enable the test case for SI-7344 when this is fixed.
        Hide
        Iulian Dragos added a comment -

        Another reason to stop removing annotations from the AST (the annotations are moved to the corresponding symbol during type-checking)...

        Show
        Iulian Dragos added a comment - Another reason to stop removing annotations from the AST (the annotations are moved to the corresponding symbol during type-checking)...
        Hide
        Vlad Ureche added a comment -

        I agree it's annoying to copy annotations over in Duplicators, but having them attached to symbols makes any annotation change much easier, as there's no need to update the tree. So I guess it's Duplicators that should adapt, not the other way around.

        On the other hand, I should really look into this, copying over annotations using the invalidSyms map only copied the annotations to skolems instead of the original type params, so there may be deeper bugs that need to be addressed. Or maybe it should only track skolems?

        Show
        Vlad Ureche added a comment - I agree it's annoying to copy annotations over in Duplicators, but having them attached to symbols makes any annotation change much easier, as there's no need to update the tree. So I guess it's Duplicators that should adapt, not the other way around. On the other hand, I should really look into this, copying over annotations using the invalidSyms map only copied the annotations to skolems instead of the original type params, so there may be deeper bugs that need to be addressed. Or maybe it should only track skolems?

          People

          • Assignee:
            Vlad Ureche
            Reporter:
            Vlad Ureche
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development