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

Fix TypeEncoding losing side-effects when wrapping Unit-typed expression #884

Merged
merged 1 commit into from
Jan 18, 2021

Conversation

gsps
Copy link
Contributor

@gsps gsps commented Jan 17, 2021

TypeEncoding may drop Unit-typed expressions when wrapping them in an adaptation to Object:

object TypeEncodingEatsTrees {
  def foo(b: Boolean): Unit = {
    if (b) {
      true
    } else {
      assert(false)
      ()
    }

    ()
  }
}

The problematic transformation step:

-------------Functions-------------
def foo(b: Boolean): Unit = {
  val t: Any = if (b) {
    true
  } else {
    assert(false)
    ()
  }
  val res: Any = t
  val tmp: Any = res
  ()
}


Symbols after TypeEncoding

-------------Functions-------------
def foo(b: Boolean): Unit = {
  val t: Object = if (b) {
    Boolean(true)
  } else {
    Unit()
  }
  val res: Object = t
  val tmp: Object = res
  ()
}

What's needed is a fix for wrap that's analogous to the changes to unwrap in #818. Could've noticed that right away, my bad.

@gsps gsps requested a review from samarion January 17, 2021 13:15
@gsps gsps merged commit f8e63fe into master Jan 18, 2021
@gsps gsps deleted the fix-type-encoding-wrap-unit branch January 18, 2021 09:47
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