Skip to content

Unable to use @specialized annotation on a class with a private primary constructor #12223

Open
@OndrejSpanel

Description

@OndrejSpanel

reproduction steps

using Scala 2.13.3, 2.12.12

class Cls[@specialized(Float) A] private () {
  override def clone(): Cls[A] = new Cls[A]()
}

problem

The code does not compile, the error returned is:

constructor Cls in class Cls cannot be accessed in class Cls$mcF$sp
 Access to protected constructor Cls not permitted because
 prefix type Cls[Float] does not conform to
 class Cls$mcF$sp where the access takes place
  override def clone(): Cls[A] = new Cls[A]()

Changing the constructor from private to protected does not help.

The code is compiled without error using dotty 0.27.0-RC1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions