-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check all bounds and avoid infinite subtyping checks when intersecting denotations #1014
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
@smarter This kind of recursion, which is problematic, is only allowed for F-bounded upper types. So we always have a typebound. |
4892639
to
534276d
Compare
val tparams = tycon.tpe.typeSymbol.typeParams | ||
val bounds = tparams.map(tparam => | ||
tparam.info.asSeenFrom(tycon.tpe.normalizedPrefix, tparam.owner.owner).bounds) | ||
checkBounds(args, bounds, _.substDealias(tparams, _)) |
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.
I think you need to call traverseChildren(tree)
here too, otherwise the following compiles without errors:
class OnlyInt[T <: Int]
object Test {
type T = List[OnlyInt[String]]
}
Otherwise LGTM, I rebased the PR, addressed your style comment, and added a description to |
/rebuild |
2ee486d
to
5c6fe12
Compare
Rebased, note that there are two unadressed comments that github is hiding: |
5c6fe12
to
14a671a
Compare
@smarter Is this good to merge now? |
This is important for IDEs who want to see the full tree. The tree now gets replaced by a TypeTree in PostTyper.
Previously, bounds of a TypeDef tree were not checked. We now make sure bounds are checked everywhere in PostTyper. The previous partial check in Applications gets removed (it was not complete even for TypeApplications because sometimes bounds were not yet known when the test was performed.)
Checking bounds everywhere revealed a problem in compileStdLib, which this commit fixes.
New test that exhibited the problem is ski.scala. Previously this did not fail with a bounds violation.
This allows us to run compileStdLib without deep subtypes again.
14a671a
to
06e18c6
Compare
bb59d81
to
8141e62
Compare
Oops, pushed the wrong commit, please review 8141e62 instead. |
8141e62
to
224232d
Compare
Merging, the junit failure is due to scala/scala-jenkins-infra#158 but you can check that the tests actually succeeded so it's safe. |
Check all bounds and avoid infinite subtyping checks when intersecting denotations
This PR is based on #1012
Review by @odersky, I don't actually understand why
safeAnd
is safer than&
but it seems to work well in practice, could you explain why it works so that I can add a comment?