Open
Description
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] ^