Skip to content

this.type doesn't work with parameterised types #1554

Closed
@scabug

Description

@scabug

Scala gives errors if you try to use this in combination with parameterised types:

scala> class A { val me: this.type = this }
defined class A

scala> class B { val maybeMe: Option[this.type] = Some(this) }
<console>:5: error: type mismatch;
 found   : Some[B]
 required: Option[B.this.type]
         val maybeMe: Option[this.type] = Some(this)
                                          ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions