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

Fix type test for trait parameter arguments #12041

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 9, 2021

Fixes #11993

@odersky odersky requested a review from b-studios April 9, 2021 13:05
@odersky odersky added this to the 3.0.0 milestone Apr 9, 2021
@odersky
Copy link
Contributor Author

odersky commented Apr 9, 2021

I have added this to the 3.0 milestone, so that it is backported to 3.0 RC3. I think the previous implementation was too restrictive and risks disallowing various code that is perfectly legal. The previous failure in #3989 is more concerning in that respect than #11993.

val params = parentCls.asClass.paramGetters
val args = termArgss(app).flatten
for (param, arg) <- params.lazyZip(args) do
if !param.is(Private) then // its type can be narrowed through intersection -> a check is needed
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a good idea to check this one here, I didn't do that in #11059.

then
report.error(IllegalParameterInit(arg.tpe, paramType, param, cls), arg.srcPos)

for case app: Apply <- parentTrees do checkParamInits(app)
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, it's also a better idea to walk through the constructors.

Copy link
Contributor

@b-studios b-studios left a comment

Choose a reason for hiding this comment

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

LGTM much more thought out than my #11059

@odersky odersky merged commit 86465f4 into scala:master Apr 13, 2021
@odersky odersky deleted the fix-11993 branch April 13, 2021 14:30
@Kordyjan Kordyjan modified the milestones: 3.0.0-RC3, 3.0.1 Aug 2, 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.

Failure to infer dependently typed constructor parameter (regression)
3 participants