Skip to content

Fix #2088: Test for simple cycle in type aliases #2461

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 1 commit into from
May 22, 2017

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

val aliasUpperBound = sym.info.bounds.hi
aliasUpperBound match {
case aliasUpperBound: RefinedType if aliasUpperBound.refinedInfo == tp =>
ctx.error("illegal cyclic reference involving " + sym + " and " + aliasUpperBound.refinedName, sym.pos)
Copy link
Member

Choose a reason for hiding this comment

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

Even if this happens to explode in VarianceChecker right now, this isn't specific to VarianceChecker in any way. I would expect this to be checked in CheckNonCyclicMap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be done in CheckNonCyclicMap.

@nicolasstucki nicolasstucki force-pushed the fix-#2088 branch 2 times, most recently from 19d57f6 to ec1e057 Compare May 18, 2017 06:37
@nicolasstucki nicolasstucki requested a review from smarter May 19, 2017 16:51
case prefix: NamedType => !prefix.symbol.isStaticOwner && isInteresting(prefix.prefix)
case prefix: NamedType =>
!prefix.symbol.isStaticOwner &&
(pre.derivesFrom(sym.owner) || isInteresting(prefix.prefix))
Copy link
Member

Choose a reason for hiding this comment

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

should this be prefix.derivesFrom ? In any case could you explain why this is the correct thing to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case we are asking if the prefix Foo.A is interesting. It is as Foo extends Base (where A is defined).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be able to reduce the false positives by checking if sym if not protected or private. I will add that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, it should be prefix.derivesFrom not pre.derivesFrom

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM!

@smarter smarter merged commit b7f5bf9 into scala:master May 22, 2017
@allanrenucci allanrenucci deleted the fix-#2088 branch December 14, 2017 19:18
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