Skip to content

Port more Scala2 tests + some mixin improvements - #25573

Merged
SolalPirelli merged 5 commits into
scala:mainfrom
dotty-staging:solal/unignore-tests
Mar 24, 2026
Merged

Port more Scala2 tests + some mixin improvements#25573
SolalPirelli merged 5 commits into
scala:mainfrom
dotty-staging:solal/unignore-tests

Conversation

@SolalPirelli

@SolalPirelli SolalPirelli commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Part of #25013

How much have you relied on LLM-based tools in this contribution?

not

How was the solution tested?

you have one guess

val ownerBType = ts.toTypeKind(method.owner.info)
if (isInterface) {
superCallTargets.add(ownerBType.asClassBType)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point in recording a supercall target if we're going to emit invokestatic. Without this change a fair number of the mixin tests ported in this PR fail due to spurious super-traits.

cls.info.nonPrivateMember(sym.name).hasAltWith(_.symbol == sym)
}

/** Does `method` need a forwarder in class `cls`?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code came from c103926 on March 15, 2016.

Less than a month later, Scala2 got improvements: scala/scala@33e7106

This is porting those improvements.

* Native, making any test using `ReflectUtil` JVM-only.
*/
object ReflectUtil {
def getFieldAccessible[T: ClassTag](n: String): Field =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Scala2 version of this test util method also made fields non-final. Thankfully we don't need to do that here, because modern JDKs don't want us to do that anymore.

f[LongMap.Bin[?]]("right").set(m, null)
ReflectUtil.getFieldAccessible[LongMap.Bin[?]]("left").set(m, null)
ReflectUtil.getFieldAccessible[LongMap.Bin[?]]("right").set(m, null)
assertFalse(m.isEmpty) // no NPE, does not access left or right

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the file deleted below: the first test already existed in scala3, and the second explicitly tests behavior known to be broken that already has notes in the JVM backend source code, with a rather convoluted test due to test framework limitations, so I didn't bother trying to port it.

@SolalPirelli
SolalPirelli force-pushed the solal/unignore-tests branch 2 times, most recently from 11d4d65 to e0f777d Compare March 20, 2026 14:41
@SolalPirelli
SolalPirelli force-pushed the solal/unignore-tests branch from e0f777d to 5348f1f Compare March 23, 2026 08:01
@SolalPirelli
SolalPirelli marked this pull request as ready for review March 23, 2026 10:06
@SolalPirelli
SolalPirelli requested a review from a team as a code owner March 23, 2026 10:06

@natsukagami natsukagami left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be the best person to review this but the changes in dotc/transformchecks out with the Scala 2 changes, backend/jvm makes sense.

I have no idea about the test changes in backend/jvm though. Did the Dotty one break somehow?
And also did MixinBytecodeTests come from Scala 2?

@SolalPirelli

Copy link
Copy Markdown
Contributor Author

Thanks!

Did the Dotty one break somehow?

Yes, because now that we don't record static targets as supercall targets (see first comment in this PR), what this test was testing didn't work anymore, so I switched to the interfaces being defined in Java so the calls are recorded as supercall targets.

did MixinBytecodeTests come from Scala 2?

Yes, but they were library tests there, I moved them to the compiler because that made no sense to me.

@SolalPirelli
SolalPirelli merged commit 669f65a into scala:main Mar 24, 2026
64 checks passed
@SolalPirelli
SolalPirelli deleted the solal/unignore-tests branch March 24, 2026 07:56
@WojciechMazur WojciechMazur added this to the 3.8.4 milestone Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants