Skip to content

mimaExcludeAnnotations doesn't work with objects #689

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

Closed
lolgab opened this issue Apr 5, 2022 · 2 comments · Fixed by #713
Closed

mimaExcludeAnnotations doesn't work with objects #689

lolgab opened this issue Apr 5, 2022 · 2 comments · Fixed by #713
Assignees
Labels

Comments

@lolgab
Copy link

lolgab commented Apr 5, 2022

mimaExcludeAnnotations doesn't work with objects.
My understanding that Mima, when annotating some object Foo, excludes the object class (Foo$) but it doesn't exclude the static methods generated in the Foo class, which are incorrectly reported even if the object is annotated with an annotation in the mimaExcludeAnnotations list.

Here you find a patch with a failing unit test:

diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/app/App.scala b/functional-tests/src/test/changes-in-experimental-objects-are-ok/app/App.scala
new file mode 100644
index 0000000..f283548
--- /dev/null
+++ b/functional-tests/src/test/changes-in-experimental-objects-are-ok/app/App.scala
@@ -0,0 +1,3 @@
+object App {
+  def main(args: Array[String]): Unit = ()
+}
diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/problems.txt b/functional-tests/src/test/changes-in-experimental-objects-are-ok/problems.txt
new file mode 100644
index 0000000..e69de29
diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/A.scala b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/A.scala
new file mode 100644
index 0000000..b4d97ad
--- /dev/null
+++ b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/A.scala
@@ -0,0 +1,9 @@
+package mima
+package pkg2
+
+import mima.annotation.exclude
+
+@exclude
+object Foo {
+  def foo = 1
+}
diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/exclude.scala b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/exclude.scala
new file mode 100644
index 0000000..5cee6bb
--- /dev/null
+++ b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v1/exclude.scala
@@ -0,0 +1,5 @@
+package mima.annotation
+
+import scala.annotation.StaticAnnotation
+
+class exclude extends StaticAnnotation
diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/A.scala b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/A.scala
new file mode 100644
index 0000000..807edbd
--- /dev/null
+++ b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/A.scala
@@ -0,0 +1,7 @@
+package mima
+package pkg2
+
+import mima.annotation.exclude
+
+@exclude
+object Foo
diff --git a/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/exclude.scala b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/exclude.scala
new file mode 100644
index 0000000..5cee6bb
--- /dev/null
+++ b/functional-tests/src/test/changes-in-experimental-objects-are-ok/v2/exclude.scala
@@ -0,0 +1,5 @@
+package mima.annotation
+
+import scala.annotation.StaticAnnotation
+
+class exclude extends StaticAnnotation
@dwijnand
Copy link
Collaborator

Hehe, I just discovered this myself today (scala/scala3#14976). Thanks for the report!

@dwijnand dwijnand self-assigned this Aug 2, 2022
@SethTisue
Copy link
Collaborator

SethTisue commented Aug 2, 2022

Making it work for methods on the object itself is a one-line change. But Dale is looking into how hard it might be to have it also recursively apply to things nested inside the object, since that would need to work in order to remove the workaround in 14976. (And if nesting inside object is fixable, that should apply to things nested inside class, too, not just object, even though we don't have a ticket on that, I don't think.)

@SethTisue SethTisue self-assigned this Aug 2, 2022
@dwijnand dwijnand linked a pull request Aug 3, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants