Skip to content

Fix #3252: Generalize constraint handling when harmonizing #3275

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
Oct 8, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 6, 2017

When harmonizing repeated arguments we needed to backtrack the
constraint. It turns out we need to do the same thing in all other
situations where harmonization takes place.

When harmonizing repeated arguments we needed to backtrack the
constraint. It turns out we need to do the same thing in all other
situations where harmonization takes place.
@odersky odersky requested a review from allanrenucci October 6, 2017 11:07
@odersky odersky changed the title Fix #3253: Generalize constraint handling when harmonizing Fix #3252: Generalize constraint handling when harmonizing Oct 6, 2017
@odersky
Copy link
Contributor Author

odersky commented Oct 6, 2017

Fixes #3252

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

LGTM

@allanrenucci
Copy link
Contributor

allanrenucci commented Oct 8, 2017

Actually scalac can harmonize even further:

def totalDuration(results: List[Long], cond: Boolean): Long =
  results.map { r =>
    if (cond) r
    else if (cond) 0
    else (1: Short)
  }.sum

Dotty doesn't handle nested control structures

@allanrenucci
Copy link
Contributor

In scalac:

scala> def foo(cond: Boolean) = if (cond) (0: Short) else if (cond) 1 else 2L
foo: (cond: Boolean)Long

In Dotty with this patch:

scala> def foo(cond: Boolean) = if (cond) (0: Short) else if (cond) 1 else 2L 
def foo(cond: Boolean): AnyVal

@odersky
Copy link
Contributor Author

odersky commented Oct 8, 2017

Yes, the differences with scalac are as expected.

@odersky odersky merged commit badc855 into scala:master Oct 8, 2017
@allanrenucci allanrenucci deleted the fix-#3253-2 branch December 14, 2017 19:18
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