subtypep working backwards
Hi Loic, my testing shows the semantics of isAssignableFrom
to be super.isAssignableFrom(sub)
.
Are you sure the implementation of subtypep
is correct?
The following code prints true, false. Which leads me to believe isAssignableFrom
is a supertypep method.
println(classOf[java.lang.Number].isAssignableFrom(classOf[java.lang.Long]))
println(classOf[java.lang.Long].isAssignableFrom(classOf[java.lang.Number]))
It seems to me that your code for subtypep
is backwards.
override def subtypep(t: Type): Option[Boolean] = {
t match {
// super.isAssignableFrom(sub) means sub is subtype of super
case tp: AtomicType if this.T.isAssignableFrom(tp.T) => Some(true)
// TODO : Other cases ? Interfaces ?
case _ => None
}
}
Can you please verify?