Skip to content
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

Improve result of bridge in delambdafy #10831

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

som-snytt
Copy link
Contributor

@scala-jenkins scala-jenkins added this to the 2.13.16 milestone Aug 10, 2024
@som-snytt som-snytt force-pushed the issue/13022-CCE-delambda-result branch from d871494 to 01a1f69 Compare August 12, 2024 22:48
@som-snytt som-snytt marked this pull request as ready for review August 13, 2024 01:30
@@ -244,7 +254,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
}

val bridge = postErasure.newTransformer(unit).transform(DefDef(methSym, List(bridgeParams.map(ValDef(_))),
adaptToType(forwarderCall setType functionResultType, bridgeResultType))).asInstanceOf[DefDef]
adaptToType(forwarderCall.setType(forwarderType), bridgeResultType))).asInstanceOf[DefDef]
Copy link
Member

@lrytz lrytz Aug 22, 2024

Choose a reason for hiding this comment

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

IIUC the issue you're addressing is the same (in opposite direction) as the one addressed 10 lines above for arguments. I like that this existing fix is more local.

Could we do this instead?

        val forwarderActualType =
          if (samResultType.isInstanceOf[ErasedValueType] && functionResultType.isInstanceOf[ErasedValueType]) bridgeResultType
          else functionResultType

and then

Suggested change
adaptToType(forwarderCall.setType(forwarderType), bridgeResultType))).asInstanceOf[DefDef]
adaptToType(forwarderCall.setType(forwarderActualType), bridgeResultType))).asInstanceOf[DefDef]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I didn't simplify the expression.

@som-snytt som-snytt force-pushed the issue/13022-CCE-delambda-result branch from 01a1f69 to 09e01ab Compare August 22, 2024 16:03
Co-authored-by: Lukas Rytz <lukas.rytz@gmail.com>
@som-snytt som-snytt force-pushed the issue/13022-CCE-delambda-result branch from 09e01ab to 76d095f Compare October 30, 2024 01:37
@som-snytt
Copy link
Contributor Author

Rebased and removed debug option in test.

@lrytz lrytz merged commit 854ef0a into scala:2.13.x Oct 30, 2024
3 checks passed
@som-snytt som-snytt deleted the issue/13022-CCE-delambda-result branch October 30, 2024 14:15
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.

ClassCastException on Value Class when implementing an interface using a Single Abstract Method
3 participants