Skip to content

Conversation

@hamzaremmal
Copy link
Member

If the type of a val is a TermRef, generating the generic signature based on the underlying type will produce the type scala.Function0<underlying>. The reason behind this is that during the getters phase, the same symbol will now refer to the getter where the type will be => <underlying>. Since the TermRef originally intended to capture the underlying type of a val, we recover that information by directly checking the resultType of the getter.

Closes #24553

@hamzaremmal hamzaremmal requested review from lrytz and sjrd November 27, 2025 21:56
@hamzaremmal hamzaremmal added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Nov 27, 2025
@hamzaremmal hamzaremmal added this to the 3.8.0 milestone Nov 27, 2025
jsig(erasedUnderlying, toplevel = toplevel, unboxedVCs = unboxedVCs)
else typeParamSig(ref.paramName.lastPart)

case ref: TermRef if ref.symbol.isGetter =>
Copy link
Member Author

Choose a reason for hiding this comment

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

Equivalent in TypeErasure:

private def underlyingOfTermRef(tp: TermRef)(using Context) = tp.widen match
case tpw @ MethodType(Nil) if tp.symbol.isGetter => tpw.resultType
case tpw => tpw

public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public int Foo.x()
Copy link
Member Author

Choose a reason for hiding this comment

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

Before this fix, we would have gotten:

public scala.Function0<java.lang.Object> Foo.x()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MIMA Binary compatibility breakage updating export of val from Scala 3.7.4 -> 3.8.0-RC1

3 participants