-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow autotupling if fn's param is a type param #21741
Allow autotupling if fn's param is a type param #21741
Conversation
formals.length == 1 && ptIsCorrectProduct(formals.head, args) | ||
formals.lengthIs == 1 && { | ||
ptIsCorrectProduct(formals.head, args) | ||
| formals.head.dealias.isInstanceOf[TypeParamRef] // eg. i21682 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need an explanation what goes on here and why the test is necessary and sufficient. Right now I have no idea what goes on here.
d93cc60
to
9d2aeac
Compare
// See i21682 for an example. | ||
val tup = defn.tupleType(args.map(v => if v.tpt.isEmpty then WildcardType else typedAheadType(v.tpt).tpe)) | ||
val TypeBounds(lo, hi) = formal.paramInfo | ||
lo <:< tup && tup <:< hi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I experimented pushing this change into ptIsCorrectProduct
and extending it to TypeVar
. That way, given that ptIsCorrectProduct
is already used by typedFunctionValue
, we would allow code like this, from tests/neg/function-arity.scala
, to compile:
def unary[T](x: T => Unit) = ???
unary((x, y) => ()) // error
Are we interested in that working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, now it's clearer!
Fixes #21682