Skip to content

Fix #8501: Run closure adaptation in Erasure.etaExpand #8519

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

Merged
merged 1 commit into from
Mar 11, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented Mar 11, 2020

Erasure.Boxing.etaExpand generates closures, but did not run the same closure
adaptation code used in Erasure#typedClosure which could lead to
type mismatches at runtime when invoking it. Fixed by moving out the
adaptation logic from Erasure#typedClosure into
Erasure.Boxing.adaptClosure and reusing this in
Erasure.Boxing.etaExpand.

This fixes tests/run/context-functions.scala on Java 11.

Also make sure ctx.typer is correctly set at Erasure (I'm surprised this
didn't come up before), otherwise adaptClosure won't work.

Erasure.Boxing.etaExpand generates closures, but did not run the same closure
adaptation code used in Erasure#typedClosure which could lead to
type mismatches at runtime when invoking it. Fixed by moving out the
adaptation logic from Erasure#typedClosure into
Erasure.Boxing.adaptClosure and reusing this in
Erasure.Boxing.etaExpand.

This fixes tests/run/context-functions.scala on Java 11.

Also make sure ctx.typer is correctly set at Erasure (I'm surprised this
didn't come up before), otherwise adaptClosure won't work.
@smarter smarter force-pushed the adapt-shortcut-closure branch from b63f878 to d3c252d Compare March 11, 2020 17:58
@smarter
Copy link
Member Author

smarter commented Mar 11, 2020

Merging this now to get it in the next nightly but I"ll still take review comments into account.

@smarter smarter merged commit a2354a8 into scala:master Mar 11, 2020
@smarter smarter deleted the adapt-shortcut-closure branch March 11, 2020 22:14
@@ -101,7 +101,7 @@ class Erasure extends Phase with DenotTransformer {

def run(implicit ctx: Context): Unit = {
val unit = ctx.compilationUnit
unit.tpdTree = eraser.typedExpr(unit.tpdTree)(ctx.fresh.setPhase(this.next))
unit.tpdTree = eraser.typedExpr(unit.tpdTree)(ctx.fresh.setTyper(eraser).setPhase(this.next))
Copy link
Contributor

Choose a reason for hiding this comment

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

Amazing that this worked before. Or was typer set by other means?

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

2 participants