Skip to content

@specialized code reports type mismatch in the presence of miniboxing but succeeds with -P:minibox:mark-all #235

@biboudis

Description

@biboudis

The following snippet reproduces the errors I got:

import scala.reflect.ClassTag

class Stream[@specialized(Long) T: ClassTag](val loop : (T => Boolean) => Boolean) {
  def map [@specialized(Long) R : ClassTag] (f: T => R) : Stream[R] = {
    new Stream(k => loop(value => k(f(value))))
  }
}

object Stream {
  @inline def apply[@specialized(Long) T: ClassTag](xs: Array[T]) = ???
}

and the sbt file:

version := "1.0"

scalaVersion := "2.11.6"

resolvers ++= Seq(Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots"))

libraryDependencies ++= Seq(
  "org.scala-lang" % "scala-reflect" % "2.11.4",
  "org.scala-miniboxing.plugins" %% "miniboxing-runtime" % "0.4-M4"
)

ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }

addCompilerPlugin("org.scala-miniboxing.plugins" %% "miniboxing-plugin" % "0.4-M4")
// scalacOptions ++= Seq("-P:minibox:mark-all")

Leaving the last line commented out, I get:

> compile
[info] Compiling 1 Scala source to /home/bibou/Projects/test-functions-miniboxing-specialized/target/scala-2.11/classes...
[error] /home/bibou/Projects/test-functions-miniboxing-specialized/src/main/scala/Stream.scala:5: type mismatch;
[error]  found   : T
[error]  required: Long => Boolean
[error]     new Stream(k => loop(value => k(f(value))))
[error]                                   ^
[error] one error found
[error] (compile:compile) Compilation failed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions