Skip to content

Scala does not see type method annotations in macros #9755

Open
@scabug

Description

@scabug

I faced pretty strange annotations-related behavior (bug?) with scala macro. Its pretty hard to describe it in one message so I decided to create a sample repo to show it.

https://github.com/akozhemiakin/sandbox-one

In brief, here is the test itself:

package sandbox

import org.scalatest.FunSuite
import sandbox.sub.B

class SandboxSpec extends FunSuite {
  class A[T](el: T)

  test("Test 1") {
    // Here we use simple macro to return number of annotations attached to the "foo" method of the A type arg
    assert(Macro.annosOnFoo(new A(new C)) == 1) // Will succeed
  }

  test("Test 2") {
    // Exactly the same case as above. The only difference: B is not in the same package as A and this test
    assert(Macro.annosOnFoo(new A(new B)) == 1) // Will fail
  }
}

So the problem is, that in the second case scala does not see any annotations attached to the target method.

I did my best to find some similar issue but did not succeed, hope it is not a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions