Skip to content

Fix #7778: infer parameter type for contextual functions #9075

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 9 commits into from
Jun 1, 2020

Conversation

liufengyun
Copy link
Contributor

Fix #7778: infer parameter type for contextual functions

Given a contextual function of the form

(using x1, ..., xN) => f

If f is a contextual function type of the form (T1, ..., TN) ?=> T,
then give the type T1 to x1 and so on.

Given a contextual function of the form

    (using x1, ..., xN) => f

If `f` is a contextual function type of the form `(T1, ..., TN) ?=> T`,
then give the type `T1` to `x1` and so on.
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

lazy val calleeType: Type = fnBody match {
lazy val calleeType: Type = untpd.stripAnnotated(fnBody) match {
case ident: untpd.Ident if isContextual =>
val tp = typedIdent(ident, WildcardType).tpe.widen
Copy link
Contributor

Choose a reason for hiding this comment

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

tp is commonly used for types. I suggest ident1 instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here tp is a type, not a tree.

@odersky odersky assigned liufengyun and unassigned odersky Jun 1, 2020
@liufengyun liufengyun merged commit b2ce6b4 into scala:master Jun 1, 2020
@liufengyun liufengyun deleted the fix-7778 branch June 1, 2020 20:49
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.

Implicit Function Type in Case Class Causes Compiler Error
2 participants