diff options
Diffstat (limited to 'test/files/jvm/opt_value_class')
-rw-r--r-- | test/files/jvm/opt_value_class/Value_1.scala | 28 | ||||
-rw-r--r-- | test/files/jvm/opt_value_class/test.scala | 16 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/files/jvm/opt_value_class/Value_1.scala b/test/files/jvm/opt_value_class/Value_1.scala new file mode 100644 index 0000000000..2440609b9e --- /dev/null +++ b/test/files/jvm/opt_value_class/Value_1.scala @@ -0,0 +1,28 @@ +final class Opt[+A >: Null](val value: A) extends AnyVal { + def get: A = value + def isEmpty = value == null +} +object Opt { + final val None = new Opt[Null](null) + def unapply[A >: Null](x: A): Opt[A] = if (x == null) None else Opt(x) + def empty[A >: Null] = None + def apply[A >: Null](value: A): Opt[A] = if (value == null) None else new Opt[A](value) +} + +class ValueExtract { + def unapply(x: Any): Opt[String] = x match { + case _: String => Opt("String") + case _: List[_] => Opt("List") + case _: Int => Opt("Int") + case _ => Opt.None + } +} + +class Direct { + def unapply(x: Any): String = x match { + case _: String => "String" + case _: List[_] => "List" + case _: Int => "Int" + case _ => null + } +} diff --git a/test/files/jvm/opt_value_class/test.scala b/test/files/jvm/opt_value_class/test.scala new file mode 100644 index 0000000000..7aea7deb99 --- /dev/null +++ b/test/files/jvm/opt_value_class/test.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.BytecodeTest + +// import scala.tools.nsc.util.JavaClassPath +// import java.io.InputStream +// import scala.tools.asm +// import asm.ClassReader +// import asm.tree.{ClassNode, InsnList} +// import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode1 = loadClassNode("ValueExtract") + val classNode2 = loadClassNode("Direct") + sameMethodAndFieldDescriptors(classNode1, classNode2) + } +} |