Skip to content

2.12 specialization compilation error #11258

Open
@kamilkloch

Description

@kamilkloch

Scala 2.12.7, the following snippet compiles:

 class ArrayGeneric[T: ClassTag](private var cacheSize: Int) {
    val arr: Array[T] = Array.ofDim[T](cacheSize)
  }

If we remove @specialized and drop private for cacheSize it compiles as well:

  class ArraySpecialized1[@specialized(Double) T: ClassTag](var cacheSize: Int) {
    val arr: Array[T] = Array.ofDim[T](cacheSize)
  }

If we remove @specialized only, compilation fails.

  class ArraySpecialized2[@specialized(Double) T: ClassTag](var cacheSize: Int) {
    val arr: Array[T] = Array.ofDim[T](cacheSize)
  }
[error] [...]: Int does not take parameters
[error]   val arr: Array[T] = Array.ofDim[T](cacheSize)
[error]                                      ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions