`mimaExcludeAnnotations` doesn't work with `object`s
lolgab opened this issue · 2 comments
mimaExcludeAnnotations
doesn't work with object
s.
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
Hehe, I just discovered this myself today (scala/scala3#14976). Thanks for the report!
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.)