-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
19d57f6
to
ec1e057
Compare
case prefix: NamedType => !prefix.symbol.isStaticOwner && isInteresting(prefix.prefix) | ||
case prefix: NamedType => | ||
!prefix.symbol.isStaticOwner && | ||
(pre.derivesFrom(sym.owner) || isInteresting(prefix.prefix)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.