Skip to content

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

Merged
merged 6 commits into from
Jan 18, 2016

Conversation

smarter
Copy link
Member

@smarter smarter commented Dec 30, 2015

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?

@smarter smarter mentioned this pull request Dec 30, 2015
@odersky
Copy link
Contributor

odersky commented Jan 6, 2016

@smarter This kind of recursion, which is problematic, is only allowed for F-bounded upper types. So we always have a typebound.

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, _))
Copy link
Member Author

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]]
}

@smarter
Copy link
Member Author

smarter commented Jan 10, 2016

Otherwise LGTM, I rebased the PR, addressed your style comment, and added a description to safe_&: https://github.com/lampepfl/dotty/pull/1014/files#diff-ca3386647f5386b6f70e99f1a9e188cdR710

@smarter
Copy link
Member Author

smarter commented Jan 13, 2016

/rebuild

@smarter smarter force-pushed the fix/deep-subtypes branch 2 times, most recently from 2ee486d to 5c6fe12 Compare January 17, 2016 14:07
@smarter
Copy link
Member Author

smarter commented Jan 17, 2016

@odersky
Copy link
Contributor

odersky commented Jan 18, 2016

@smarter Is this good to merge now?

odersky and others added 5 commits January 18, 2016 16:49
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.
@smarter
Copy link
Member Author

smarter commented Jan 18, 2016

@odersky : please review bb59d81 and then we can merge. (we'll document the empty TypeBounds trick another time).

@smarter
Copy link
Member Author

smarter commented Jan 18, 2016

Oops, pushed the wrong commit, please review 8141e62 instead.

@smarter
Copy link
Member Author

smarter commented Jan 18, 2016

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.

smarter added a commit that referenced this pull request Jan 18, 2016
Check all bounds and avoid infinite subtyping checks when intersecting denotations
@smarter smarter merged commit 1aa8fbb into scala:master Jan 18, 2016
@smarter smarter changed the title Avoid infinite subtyping checks when intersecting denotations Check all bounds and avoid infinite subtyping checks when intersecting denotations Jan 18, 2016
@allanrenucci allanrenucci deleted the fix/deep-subtypes branch December 14, 2017 19:22
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