Skip to content

Opaque types not allowed in a class #6227

Closed
@panacekcz

Description

@panacekcz

Although all the examples of opaque types define them in objects, I didn't see any mention in the proposal of opaque types being intentionally disallowed in classes, so I guess it is an issue of the implementation.

Test code:

class C {
  opaque type T = Int
}

Output:

-- Error: opaque-class.scala:2:2 -----------------------------------
2 |  opaque type T = Int
  |  ^
  |type T in object T cannot be accessed as a member of C.this.T.type from class C.
one error found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions