dotty-knowledge icon indicating copy to clipboard operation
dotty-knowledge copied to clipboard

Seeming typo in example code for opaques

Open IDisposable opened this issue 3 years ago • 1 comments

In the section on Bounds For Opaque Type Aliases

The example code block

object Access:

  opaque type Permissions = Int
  opaque type PermissionChoice = Int
  opaque type Permission <: Permissions & PermissionChoice = Int

  extension (x: Permissions)
    def & (y: Permissions): Permissions = x | y
  extension (x: PermissionChoice)
    def | (y: PermissionChoice): PermissionChoice = x | y

Seems to be wrong in that the & and the | both are doing x | y in the body. I suspect that the first one should actually be x & y like this.

    def & (y: Permissions): Permissions = x & y

IDisposable avatar Jul 01 '21 00:07 IDisposable