Skip to content

Use WildcardType in place of a type variable in pretypeArgs #3974

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
Feb 12, 2018

Conversation

allanrenucci
Copy link
Contributor

As discussed during the meeting. Let's see if it passes the tests

@allanrenucci allanrenucci requested a review from odersky February 7, 2018 18:51

def combine(f: (Char, Int) => Int): Int = ???
def combine(f: (String, Int) => String): String = ???
val r5 = combine((x: Char, y) => x + y)
val t5: Int = r5
val r6 = combine((x: String, y) => x ++ y.toString)
val t6: String = r6

// Errors: The argument types of an anonymous function must be fully known
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@odersky Is this intended? Should I open an issue for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine; we don't look inside tuples here. What does scalac say?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested on Scala 2.13.0-M2:

[error] constructor cannot be instantiated to expected type;
[error]  found   : (T1, T2)
[error]  required: Char
[error]   bar { case (x, y) => () }
[error]              ^

[warn] match may not be exhaustive.
[warn] It would fail on the following input: (_, _)
[warn]   val rp5 = combine { case (x: Char, y) => x + y }
[warn]                     ^

[warn] match may not be exhaustive.
[warn] It would fail on the following input: (_, _)
[warn]   val rp6 = combine { case (x: String, y) => x ++ y.toString }
[warn]                     ^
[warn] two warnings found

In two out of tree of the cases scalac is able to find the correct overload. It emits a spurious exhaustivity warning though


def combine(f: (Char, Int) => Int): Int = ???
def combine(f: (String, Int) => String): String = ???
val r5 = combine((x: Char, y) => x + y)
val t5: Int = r5
val r6 = combine((x: String, y) => x ++ y.toString)
val t6: String = r6

// Errors: The argument types of an anonymous function must be fully known
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine; we don't look inside tuples here. What does scalac say?

@allanrenucci allanrenucci merged commit a09f385 into scala:master Feb 12, 2018
@allanrenucci allanrenucci deleted the pretypeArgs branch February 12, 2018 11:04
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