Skip to content

Fix #8337: Flag F-bounded opaque types as errors #8412

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
Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2596,8 +2596,8 @@ object Types {
/** Update the value of the lazyref, discarding the compute function `refFn`
* Can be called only as long as the ref is still undefined.
*/
def update(tp: Type) =
assert(myRef == null)
def update(tp: Type)(using ctx: Context) =
assert(myRef == null || ctx.reporter.errorsReported)
myRef = tp
computed = true
refFn = null
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/other-new-features/opaques-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The general form of a (monomorphic) opaque type alias is
```scala
opaque type T >: L <: U = R
```
where the lower bound `L` and the upper bound `U` may be missing, in which case they are assumed to be `scala.Nothing` and `scala.Any`, respectively. If bounds are given, it is checked that the right hand side `R` conforms to them, i.e. `L <: R` and `R <: U`.
where the lower bound `L` and the upper bound `U` may be missing, in which case they are assumed to be `scala.Nothing` and `scala.Any`, respectively. If bounds are given, it is checked that the right hand side `R` conforms to them, i.e. `L <: R` and `R <: U`. F-bounds are not supported for opaque types: `T` is not allowed to appear in `L` or `U`.

Inside the scope of the alias definition, the alias is transparent: `T` is treated
as a normal alias of `R`. Outside its scope, the alias is treated as the abstract type
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i8337.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait Foo[F <: Foo[F]]
class Bar extends Foo[Bar]

object Q { // error: recursion limit exceeded
opaque type X <: Foo[X] = Bar // error: out of bounds
}