Skip to content
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

Support implicit arguments before extractor method #18671

Merged

Conversation

EnzeXing
Copy link
Contributor

@EnzeXing EnzeXing commented Oct 9, 2023

Currently the global object initialization checker crashes when encountering implicit arguments in extractor methods that are before scrutinee. This PR fixes the issue and adds tests with implicit arguments before scrutinee for unapply and unapplySeq respectively.

@EnzeXing
Copy link
Contributor Author

@liufengyun @olhotak I have corrected the argument order in evalPattern. The original tests are not sufficient to show the previous error by using the implicit arguments, so I have added more tests to reflect that. The errors in unapply-implicit-arg3.scala and unapplySeq-implicit-arg3.scala can only be caught when the argument order is correct.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @EnzeXing !

case _ => List()

val implicitValuesAfterScrtinee = evalArgs(implicits.map(Arg.apply), thisV, klass)
val unapplyRes = call(receiver, funRef.symbol, implicitValuesBeforeScrutinee(fun) ++ (TraceValue(scrutinee, summon[Trace]) :: implicitValuesAfterScrtinee), funRef.prefix, superType = NoType, needResolve = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: This line is a little long , maybe extract implicitValuesBeforeScrutinee(fun) ++ (TraceValue(scrutinee, summon[Trace]) :: implicitValuesAfterScrtinee) to a local definition.

Copy link
Contributor

@olhotak olhotak 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.

@olhotak olhotak merged commit 69e1338 into scala:main Oct 16, 2023
16 checks passed
@olhotak olhotak deleted the object-initialization-implicit-unapply branch October 16, 2023 20:13
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
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.

None yet

4 participants