Skip to content

Fix #3246: Refine handling of postfix _ for non-functions #3402

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
Nov 1, 2017

Conversation

allanrenucci
Copy link
Contributor

Reopening #3300 from dotty-staging

@allanrenucci
Copy link
Contributor Author

This used to compile but doesn't compile anymore:

class Test {
  class A
  def foo(x: A)(y: x.type) = ()
  val bar = foo(new A()) _
 }
-- Error: tests/allan/Test.scala:4:25 ------------------------------------------
4 |  val bar = foo(new A()) _
  |            ^^^^^^^^^^^^^^
  |            not a function: foo(new A()); cannot be followed by `_'

one error found

@allanrenucci
Copy link
Contributor Author

Same for:

class Test {
  class A {
    type T
    def f(x: T): T = ???
  }
  def a: A = new A
  val f = a.f _
 }
-- Error: tests/allan/Test.scala:7:14 ------------------------------------------
7 |  val f = a.f _
  |          ^^^^^
  |          not a function: a.f; cannot be followed by `_'

one error found

@liufengyun
Copy link
Contributor

@allanrenucci The two examples don't compile by 2.12.3, do we need to support in Dotty?

@allanrenucci
Copy link
Contributor Author

They compile on Dotty master and are extracted from our test suite.

I believe the second example should probably compile or at least this should compile (it compiles with scalac):

class Test {
  class A {
    type T = Int
    def f(x: T): T = ???
  }
  def a: A = new A
  val f = a.f _
}

Regarding the first example, I am not sure

@liufengyun
Copy link
Contributor

It works now, review @allanrenucci , thanks.

@allanrenucci
Copy link
Contributor Author

LGTM. Thanks!

@allanrenucci allanrenucci merged commit c8411af into scala:master Nov 1, 2017
@allanrenucci allanrenucci deleted the fix-#3246 branch November 1, 2017 14:02
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.

3 participants