Type inequality in shapeless does not seem to be safe once type parameters enter the picture.
For example the following code compiles
def someMethod[T](in : T) = {
implicitly[T =:!= String]
// some operation that requires T not String could be called here
// even though there is no guarantee that this is safe
}
val a = someMethod("abc") // here we have just proven String != String
My intuition is that the correct behavior should be a compile time error (we have generated a proof that String =!:= String
)
This is not related to the =:!=
operator but to all situations in which implicit conflicts are used to emulate a negation operator.
Is this really a bug or am I missing an important point?
T =:!= String
needs to be an implicit argument ofsomeMethod
. We need to collect the evidence thatT
is not aString
at the call site, otherwise it's too late.T
is erased within the body ofsomeMethod
.