Skip to content

Disallow phantom type parameter/member in classes #2442

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

Conversation

nicolasstucki
Copy link
Contributor

This fixes potential ways to fake evidences by casting an object that has a phantom type parameter/member. See neg/phantom-class-type-parameters.scala as an example.

else if (!isParam && isPhantom && !tdef.symbol.owner.isStaticOwner)
ctx.error("Non static classes cannot have phantom type members", tdef.pos)
tdef
}
Copy link
Contributor

Choose a reason for hiding this comment

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

A small comment: may this be done in RefChecks where a lot of checking happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try. I also felt uneasy adding all those checks in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it to Checking

@nicolasstucki nicolasstucki requested review from OlivierBlanvillain and removed request for odersky May 22, 2017 07:29
@nicolasstucki nicolasstucki removed this from the 0.1 Tech Preview milestone May 24, 2017
@nicolasstucki
Copy link
Contributor Author

Found a cleaner solution with #2525

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.

2 participants