-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #6253: Handle repeated args in quoted patterns #6254
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
Fix #6253: Handle repeated args in quoted patterns #6254
Conversation
7b0992f
to
6f9cd74
Compare
14eadd0
to
46e7c7a
Compare
* Handle repeated args in quoted patterns in typer * Handle repeated args in quoted patterns in Matcher * Add Repeated extractor to get Seq[Expr[T]] from a Expr[Seq[T]]
46e7c7a
to
b2679f8
Compare
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.
Otherwise, LGTM
finally { | ||
val pat1 = pat.subst(defn.RepeatedParamClass :: Nil, defn.SeqClass :: Nil) | ||
patBuf += pat1 | ||
} |
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.
The change here and above looks dubious to me. @odersky could you have a look?
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 am not sure a global substitution is the right thing here. I fear it would also affect nested varargs methods that would then become Seq methods. I'd do instead:
val patType = pat.tpe.widen
val patType1 = patType.underlyingIfRepeated(isJava = false)
val pat1 = if (patType eq patType1) pat else pat.withType(patType1)
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 use this code now and also updated another place that had the subst
to use underlyingIfRepeated
.
finally { | ||
val pat1 = pat.subst(defn.RepeatedParamClass :: Nil, defn.SeqClass :: Nil) | ||
patBuf += pat1 | ||
} |
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 am not sure a global substitution is the right thing here. I fear it would also affect nested varargs methods that would then become Seq methods. I'd do instead:
val patType = pat.tpe.widen
val patType1 = patType.underlyingIfRepeated(isJava = false)
val pat1 = if (patType eq patType1) pat else pat.withType(patType1)
I reverted the changes in Typer, and the tests in this PR pass:
I still fail to understand the rational to go to an underlying type. Could you please elaborate @nicolasstucki ? |
We want to avoid having expressions of type |
Seq[Expr[T]]
from anExpr[Seq[T]]