Grzegorz Balcerek
2011-02-16 21:25:40 UTC
Hello,
Is there a way to disable an implicit conversion?
I know I can change the way an implicit conversion works. For example:
scala> 200.toHexString
res0: String = c8
scala> implicit def intWrapper(x:Int) = new runtime.RichInt(255)
intWrapper: (x: Int)scala.runtime.RichInt
scala> 200.toHexString
res1: String = ff
Is there a way to disable the conversion?
I know can do the following as well:
scala> implicit def intWrapper(x:Int):runtime.RichInt = throw new Exception
intWrapper: (x: Int)scala.runtime.RichInt
scala> 200.toHexString
java.lang.Exception
at .intWrapper(<console>:6)
at .<init>(<console>:9)
(...)
Is there another way? Is it possible to make scala give a compile error instead of an exception?
Regards,
Grzegorz Balcerek
Is there a way to disable an implicit conversion?
I know I can change the way an implicit conversion works. For example:
scala> 200.toHexString
res0: String = c8
scala> implicit def intWrapper(x:Int) = new runtime.RichInt(255)
intWrapper: (x: Int)scala.runtime.RichInt
scala> 200.toHexString
res1: String = ff
Is there a way to disable the conversion?
I know can do the following as well:
scala> implicit def intWrapper(x:Int):runtime.RichInt = throw new Exception
intWrapper: (x: Int)scala.runtime.RichInt
scala> 200.toHexString
java.lang.Exception
at .intWrapper(<console>:6)
at .<init>(<console>:9)
(...)
Is there another way? Is it possible to make scala give a compile error instead of an exception?
Regards,
Grzegorz Balcerek