leer Merkmal Test definiert:Fall Klasse Begleitobjekt Generierungsfehler für Verbindungstyp
trait Test
was in Verbindung Typ verwendet:
scala> val a : Int with Test = 10.asInstanceOf[Int with Test]
a: Int with Test = 10
und Fall-Klasse mit dem Parameter des Verbindungstypen (wie Unboxed Tagged Typ):
scala> case class Foo(a: Int with Test)
error: type mismatch;
found : Double
required: AnyRef
Note: an implicit exists from scala.Double => java.lang.Double, but
methods inherited from Object are rendered ambiguous. This is to avoid
a blanket implicit which would convert any scala.Double to any AnyRef.
You may wish to use a type ascription: `x: java.lang.Double`.
Aber es perfekt für sich arbeiten:
scala> case class Foo(a: List[Int] with Test)
defined class Foo
Und kein Problem mit Methodendefinition:
scala> def foo(a: Int with Test) = ???
foo: (a: Int with Test)Nothing
Scala Version 2.10.3
Ist es normal, Compiler Verhalten?
Dies ist ein [bekanntes Problem] (https://issues.scala-lang.org/browse/SI-5183). –