-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement sealed type parameters #17422
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
|
Hi Yichen, Can you review, and in particular double check that the changes to tests in ce3b6d2 all make sense? I.e. that there's nothing slipping through that should be caught. |
| import language.experimental.captureChecking | ||
|
|
||
| // compare with neg-custom-args/captures/depfun.scala, which produces errors | ||
| // but the errors go away if ->{} gets replaced by ->. | ||
|
|
||
| trait Cap { def use(): Unit } | ||
|
|
||
| def main() = { | ||
| val f: (io: Cap^) -> () -> Unit = | ||
| io => () => io.use() // error | ||
|
|
||
| val g: (Cap^) -> () -> Unit = | ||
| io => () => io.use() // error | ||
| } |
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.
This inconsistency can be reproduced before this PR. It seems that this is a result of expandAbbreviations:
https://github.com/lampepfl/dotty/blob/9ed9839e533db22c69bdb1e552ef6eeaacecc333/compiler/src/dotty/tools/dotc/cc/Setup.scala#L286-L296
Linyxus
left a comment
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!
Previously we sometimes got a "non=private definition with nonempty capturing type needs explicit type ascription error" that hid a more important error such as a leaking universal capture set.
Abolish restriction that box/unbox cannot be done with `cap`.
Instead, do a deep check for `cap`
- in type arguments for `sealed` type variables
- in the types of mutable vars
- in the type of `try` under the `saferExceptions` language import
The caps.unsafe.{unsafeBox, unsafeUnbox, unsafeBoxFunArg} methods are not longer
needed and are deprecated. Instead there is an annotation annotation.unchecked.uncheckedCaptures that
can be added to a mutable variable to turn off checking its type.
These changes in behavior are introduced in 3.3. Older source versions
still support the old behavior (which corresponds to the paper).
So to run examples in the paper as described there, they need a `-source 3.2` or a
language import.
import language.`3.2`.
9ed9839 to
a8f583d
Compare
Abolish restriction that box/unbox cannot be done with
cap.Instead, do a deep check for
capsealedtype variablestryunder thesaferExceptionslanguage importThe
caps.unsafe.{unsafeBox, unsafeUnbox, unsafeBoxFunArg}methods are not longerneeded and are deprecated. Instead there is an annotation
annotation.unchecked.uncheckedCapturesthatcan be added to a mutable variable to turn off checking its type.
These changes in behavior are introduced in 3.3. Older source versions
still support the old behavior (which corresponds to the paper).
So to run examples in the paper as described there, they need a
-source 3.2or alanguage import.
Based on #17377