Skip to content

Sharpen a type in Inliner #5884

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
Feb 8, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 8, 2019

Replace some MemerDefs by ValorDefDefs.

@odersky odersky added the fasttrack Simple fix. Reviewer should merge or apply additional changes directly. label Feb 8, 2019
@odersky
Copy link
Contributor Author

odersky commented Feb 8, 2019

@nicolasstucki I remembered the reason why we should not inline by-name-parameters before typing: The by-name parameter might appear multiple times in different branches of an inline match or inline if. For instance, here's the case of the trace.conditionally macro:

  def conditionally[TC](cond: Boolean, question: => String, show: Boolean)(op: => TC)(implicit ctx: Context): TC =
    if (Config.tracingEnabled) {
      def op1 = op
      if (cond) apply[TC](question, Printers.default, show)(op1)
      else op1
    } else op

op (which is usually a large expression) appears twice in the body. After typechecking the inner if, only one branch will remain, since Config.,tracingEnabled is an inline val. But if we substitute immediately, we create and typecheck two copies of the argument.

@nicolasstucki nicolasstucki merged commit 8cce121 into scala:master Feb 8, 2019
@nicolasstucki nicolasstucki deleted the simplify-inliner branch February 8, 2019 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fasttrack Simple fix. Reviewer should merge or apply additional changes directly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants