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
Remove by-name restriction for case copy #10770
base: 2.13.x
Are you sure you want to change the base?
Conversation
6b329bf
to
7b8b267
Compare
I think we have to as it's changing the binary output. |
7b8b267
to
914c657
Compare
val classParamss = constrParamss(cdef) | ||
def warn() = runReporting.warning(cdef.namePos, "case `copy` method is allowed to have by-name parameters under Scala 3 (or with -Xsource-features:case-copy-by-name)", Scala3Migration, cdef.symbol) | ||
def isDisallowed(vd: ValDef) = isRepeatedParamType(vd.tpt) || isByNameParamType(vd.tpt).tap(if (_) warn()) | ||
def copyOK = currentRun.sourceFeatures.caseCopyByName || !mexists(classParamss)(isDisallowed) |
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.
now it tries to generate copy
for repeated params:
➜ sandbox scpr 10770 T.scala -Vprint:cleanup -Xsource:3-cross
> scala compile --server=false -S 2.13.15-bin-914c657-SNAPSHOT -d . -release 8 --repository https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots T.scala -Vprint:cleanup -Xsource:3-cross
/Users/luc/code/scala/scala13/sandbox/T.scala:1: error: type mismatch;
found : Seq[Int]
required: Int
case class C(x: Int)(y: Int*)
^
1 error
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, oops, I'll rename it to sourceFeatures.anythingGoes
.
914c657
to
4e5ceaa
Compare
4e5ceaa
to
9e19996
Compare
Refactored |
-Xsource-features:case-copy-by-name
synthesizes case copy method when a parameter is by-name.Fixes scala/bug#7879