There is a method testImpl which has the same behavior as the test method had in scala 2.13, but it is unfortunately marked private so I cannot call it from my subclass of AnyFunSuite.
How can I request that either this private decoration be removed, or a public method be installed which simply calls testImpl passing the arguments along?
The fact that his behavior has changed in scala 3.x is making it difficult to convert a project from 2.13 to 3.x.
Here is the code I’d like to make compile and run in scala 3.x.
I declare a subclass AdjFunSuite which overrides the test method and calls super.test(...)(...)(...).
This worked fine in scala 2.13 but in 3.x the test method is inlined and simply calls testImpl.
In my opinion either the inline should be removed, or another method should be provided so a method in an application class can call it.
I tried to get around this by copying the AnyTestSuiteLike definition locally and removing the private decoration, but this won’t make AnyTestSuite inherit from my version of AnyTestSuiteLike. I abandoned this, but I could, I suppose, also make a local copy of AnyTestSuite. But this just seems like the wrong solution.
I would also be happy if someone could suggest how to implement a function xtest which simply calls test. The problem is that since test is inlined, it gets the line number from that inlined call-site and passes that line number to testImpl. This would be horrible, because every test would get the exact same line number position, i.e., the one from the call to test inside AdjFunSuite. What we’d like is the line number position from the actual line doing the testing, i.e., the call site of xtest. But I don’t see a way to pass along the line number position to a method in AnyFunSuite because all the methods which accept the position seem to be private.
I had a conversation with chatGPT and he suggested I could call the method “testImpl” programmatically using reflection. After a few iterations with chatGPT, here is the code I came up with. It finds the method and overrides the private flag and calls the method anyway.
Note that I’m using def test not override def test because test is not an inherited method.