Skip to content

Fix #3050: Avoid retyping synthesised code #3065

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 4 commits into from
Oct 3, 2017

Conversation

biboudis
Copy link
Contributor

@biboudis biboudis commented Sep 5, 2017

This is a crude way to fix #3050's bugs with retyping inlined code involving pattern matching.

WDYT?

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Added" instead of "Add")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@biboudis biboudis changed the title Fix #3050 Fix #3050: Avoid retyping synthesised code Sep 5, 2017
@smarter
Copy link
Member

smarter commented Sep 5, 2017

The stackoverflow is spurious and unrelated to this PR, it's the same issue as #2924

@biboudis
Copy link
Contributor Author

biboudis commented Sep 5, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Sep 5, 2017

performance test scheduled: 1 jobs in total.

@allanrenucci
Copy link
Contributor

@nicolasstucki Can we open a separate PR with the last commit if it fixes #2924? I am eager to get this in as it would solve many CI failures.

def foldRightBN[U](z: => U)(op: (T, => U) => U): U = xs match {
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = xs.reverse.foldLeftBN(z)(op)

@tailrec final def foldLeftBN[U](z: => U)(op: (T, => U) => U): U = xs match {
Copy link
Contributor

Choose a reason for hiding this comment

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

foldLeft in the standard library has the accumulator as the first arg of the closure:

def foldLeft[U](z: U)(op: (U, T) => U): U

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes, z is supposed to be called acc

Copy link
Contributor

Choose a reason for hiding this comment

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

I will create a separate PR with this.

@nicolasstucki
Copy link
Contributor

You will need to remove commit 00cf7f6 and rebase.

@nicolasstucki
Copy link
Contributor

Maybe no need of rebase

@biboudis
Copy link
Contributor Author

biboudis commented Sep 6, 2017 via email

@nicolasstucki
Copy link
Contributor

It is not exactly the same code

@nicolasstucki
Copy link
Contributor

Your stack is 1/4 smaller, but it was not enough. You will need the fix in #3080.

Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain left a comment

Choose a reason for hiding this comment

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

👍

untpd.Apply(
untpd.Select(untpd.TypedSplice(tree), nme.EQ),
untpd.TypedSplice(dummyTreeOfType(pt)))
typedExpr(cmp, defn.BooleanType)(ctx.retractMode(Mode.Pattern))
Copy link
Contributor

Choose a reason for hiding this comment

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

retractMode(Pattern) is redundant (it's removed by typedExpr)

@@ -2277,4 +2269,18 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
}

protected def checkEqualityEvidence(tree: tpd.Tree, pt: Type)(implicit ctx: Context) : Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

/** Check that `tree == x: pt` is typeable. Used when checking a pattern
 *  againts a selector of type `pt`. This implementation accounts for
 *  user-defined definitions of `==`.
 *  Overwritten to no-op in ReTyper.
 */

@biboudis
Copy link
Contributor Author

biboudis commented Sep 8, 2017

@OlivierBlanvillain can you give me pointers to debug this stackoverflow with the optimised bootstrapped compiler version?

@allanrenucci
Copy link
Contributor

Have you tried with the fix in #3080?

@biboudis
Copy link
Contributor Author

biboudis commented Sep 8, 2017

@allanrenucci let's see (although I feel that it is a different error)

@biboudis
Copy link
Contributor Author

biboudis commented Sep 8, 2017

Tada! thanks @allanrenucci!

@OlivierBlanvillain OlivierBlanvillain merged commit 1f4aad6 into scala:master Oct 3, 2017
@biboudis biboudis deleted the fix-i3050 branch April 30, 2019 14:42
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.

notype when inlining pattern matching
6 participants