Skip to content

Fix #1378: Propagate more knowledge of result type into applications #1395

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 6 commits into from
Jul 21, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 16, 2016

In the presence of implicits, this a delicate dance. On the one hand, we need to propagate
knowledge of result types into applications in order to infer parameters as shown in i1378.scala.
On the other hand, we might go down a wrong path with this, if for instance we really meant to insert an implicit on the result type.

Review by @nicolasstucki or @smarter.

odersky added 3 commits July 16, 2016 15:16
Error messages were suppressed so far, now get printed.
As observed by @smarter, makes sense to do this.
If an application has functions with implicit parameter types we need to be
more aggressive about propagating knowledge of the expected result type into
the constraint.

Fixes scala#1378.
// todo: fill with methods from TreeInfo that only apply to untpd.Tree's
import TreeInfo._

def isFunctionWithImplicitParamType(tree: Tree) = tree match {
Copy link
Member

Choose a reason for hiding this comment

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

I find the use of implicit in this context confusing, how about unknown instead?

odersky added 3 commits July 17, 2016 11:05
This should have been done in a PR that was merged before.
Interestingly, adding

  mutable.BufferLike

to the whitelist succeeds under junit but fails under partest. Unfortunately I can't see
any output in the log indicating what went wrong. I only see this:

    !! 306 - pos/compileStdLib                         [compilation failed]

    # Failed test paths (this command will update checkfiles)
    test/partest --update-check \
      /Users/odersky/workspace/dotty/tests/partest-generated/pos/compileStdLib
@odersky
Copy link
Contributor Author

odersky commented Jul 18, 2016

More info on failing stdlib test: If I run the test alone in partest it succeeds. Unfortunately, this looks like we might have a race. Difficult to say without more test output. I'll make a separate issue #1401 so that we can complete this PR.

@DarkDimius
Copy link
Contributor

See #1401 (comment) for the log of failure in CI.

@nicolasstucki
Copy link
Contributor

LGTM

@odersky odersky merged commit 80a65f4 into scala:master Jul 21, 2016
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this pull request Dec 8, 2016
Generate java signatures for private members as well (scala#1395)
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this pull request Dec 12, 2016
Generate java signatures for private members as well (scala#1395)
@allanrenucci allanrenucci deleted the fix-#1378 branch December 14, 2017 16:59
smarter added a commit to dotty-staging/dotty that referenced this pull request Oct 13, 2021
This was originally added in scala#1395 to make the following compile:

    (1, x => 2): (Int, Int => Int)

But reverting this change doesn't break anything anymore: the other call
to `constrainResult` in `Application#init` is enough to propagate the
constraint needed to type lambda. The strange thing is that this call
already existed before scala#1395, I don't know why it wasn't enough back then.
olsdavis pushed a commit to olsdavis/dotty that referenced this pull request Apr 4, 2022
This was originally added in scala#1395 to make the following compile:

    (1, x => 2): (Int, Int => Int)

But reverting this change doesn't break anything anymore: the other call
to `constrainResult` in `Application#init` is enough to propagate the
constraint needed to type lambda. The strange thing is that this call
already existed before scala#1395, I don't know why it wasn't enough back then.
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.

5 participants