Created
July 20, 2010 08:08
-
-
Save kmizu/482682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyArray[A:ClassManifest:Nothing_=!=](size: Int) { | |
val array = new Array[A](size) | |
} | |
trait Nothing_=!=[A] | |
object MyArray { | |
implicit val anyIsNotNothing: Nothing_=!=[Any] = null | |
implicit def anyValIsNotNothing: Nothing_=!=[AnyVal] = null | |
implicit def refTypeIsNotNothing[A >: Null]: Nothing_=!=[A] = null | |
implicit def byteIsNotNothing: Nothing_=!=[Byte] = null | |
implicit def shortIsNotNothing: Nothing_=!=[Short] = null | |
implicit def intIsNotNothing: Nothing_=!=[Int] = null | |
implicit def longIsNotNothing: Nothing_=!=[Long] = null | |
implicit def charIsNotNothing: Nothing_=!=[Char] = null | |
implicit def floatIsNotNothing: Nothing_=!=[Float] = null | |
implicit def doubleIsNotNothing: Nothing_=!=[Double] = null | |
implicit def booleanIsNotNothing: Nothing_=!=[Boolean] = null | |
implicit def unitIsNotNothing: Nothing_=!=[Unit] = null | |
} | |
import MyArray._ | |
new MyArray[Int](3) // OK | |
new MyArray[Double](3) // OK | |
new MyArray[Any](3) // OK | |
new MyArray[AnyVal](3) // OK | |
new MyArray[Null](3) // OK | |
new MyArray[AnyRef](3) // OK | |
new MyArray[String](3) // OK | |
// new MyArray[Nothing](3) // NG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment