Skip to content
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

Typing error with PartialFunction argument in type-annotated overloaded function call #11818

Open
enzief opened this issue Dec 3, 2019 · 3 comments

Comments

@enzief
Copy link

@enzief enzief commented Dec 3, 2019

scala version: 2.12.10

scala> :paste
// Entering paste mode (ctrl-D to finish)

def f[T](p: Any => String): Option[T]  = None
def f[T](i: Int, s: String): Option[T] = None

// Exiting paste mode, now interpreting.

f: [T](p: Any => String)Option[T] <and> [T](i: Int, s: String)Option[T]
f: [T](p: Any => String)Option[T] <and> [T](i: Int, s: String)Option[T]

scala> f({ case _ => "" }): Option[Int]
res8: Option[Int] = None

scala> f[Int]({ case _ => "" }): Option[Int]
<console>:13: error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: ?
       f[Int]({ case _ => "" }): Option[Int]

expected:
f[Int]({ case _ => "" }) type checks successfully just like f({ case _ => "" })

@som-snytt

This comment has been minimized.

Copy link

@som-snytt som-snytt commented Dec 3, 2019

IDK, but TIL AntiPolyType:

// rarely used, disappears when combined with a PolyType

which sounds like instructions for Dungeons and Dragons.

At a mere glance, it looks like supplying the type arg makes it check type params and turns f into an ordinary overload, with args checked without expected type.

[log typer] Attaching AntiPolyType-carrying overloaded type to value f
@SethTisue

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Dec 5, 2019

have you tried it on Scala 2.13.1?

@som-snytt

This comment has been minimized.

Copy link

@som-snytt som-snytt commented Dec 5, 2019

(Yes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.