slick/slick — pull request #219 by hvesalai (2013-10-04 06:09:24+00:00)
Title: Allow subtypes in OptionMappers

I have an ADT defined as follows:

```
object ExampleEnumeration extends EnumerationBase {
sealed trait Value extends ValueBase
case object Foo extends Value
case object Bar extends Value
}

trait EnumerationBase {
trait ValueBase
// unrelated reflection magic here
}
```

I have defined a `BaseTypeMapper` for `[V <: EnumerationBase#ValueBase]` and a table that uses it:

```
object MyTable extends Table[(String, Value)]("mytable") {
val bang = column[String]("bang")
val biff = column[Value]("biff")
}
```

However, when using the table I was getting a compiler error:

```
for {
m <- MyTable if m.biff === Foo
} yield m.bang

Cannot perform option-mapped operation
[error] with type: (ExampleEnumeration.Value, ExampleEnumeration.Foo.type) => R
[error] for base type: (ExampleEnumeration.Value, ExampleEnumeration.Value) => Boolean
```

This is because the current `OptionMapper2` requires that `B2 =:= P2`, which is not true for `Foo <:< Value`.

A simple workaround was to just widen Foo to Value manually.

```
for {
m <- MyTable if m.biff === (Foo:Value)
} yield m.bang
```

This commit fixes OptionMappers so that the cast is not required.