Skip to content

Fix #5083: Disallow using trait parameters as prefix for its parents #5108

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

Merged
merged 4 commits into from
Sep 19, 2018

Conversation

liufengyun
Copy link
Contributor

Fix #5083: Disallow using trait parameters as prefix for its parents

The rationale is to ensure outer-related NPE never happen in Scala.
Otherwise, outer NPE may happen, see tests/neg/i5083.scala

…ents

The rationale is to ensure outer-related NPE never happen in Scala.
Otherwise, outer NPE may happen, see tests/neg/i5083.scala
Copy link
Contributor

@odersky odersky 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

@@ -960,7 +976,7 @@ class RefChecks extends MiniPhase { thisPhase =>
override def transformTemplate(tree: Template)(implicit ctx: Context) = try {
val cls = ctx.owner
checkOverloadedRestrictions(cls)
checkParents(cls)
checkParents(cls, tree)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use two different methods for checking parents:

checkParent(cls)
if (cls.is(Trait)) tree.parents.foreach(checkParentPrefix(cls, _))

That way the logic of checkParents can be left unchanged

@liufengyun liufengyun merged commit fb0347e into scala:master Sep 19, 2018
@liufengyun liufengyun deleted the fix-5083 branch September 19, 2018 14:07
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.

Compiler crash during explicitOuter
2 participants