Skip to content

Commit

Permalink
get tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek committed Jul 5, 2020
1 parent 4d29d72 commit c2ea985
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala-2.12/cats/evidence/AsSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ private[evidence] trait AsSupport {
* it just makes it not provable without the cast.
*/
@inline implicit def asFromPredef[A, B](implicit ev: A <:< B): A As B =
As.fromPredef(ev)
As.refl[A].asInstanceOf[A As B]
}
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/evidence/As.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ sealed abstract class As[-A, +B] extends Serializable {
* A value `A As B` is always sufficient to produce a similar `Predef.<:<`
* value.
*/
@inline final def toPredef: A <:< B =
substitute[<:<[*, B]](implicitly[B <:< B])
@inline final def toPredef: A <:< B = {
type F[-Z] = <:<[Z, B]
substitute[F](implicitly[B <:< B])
}
}

sealed abstract class AsInstances {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/AsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AsSuite extends CatsSuite {
{
trait Foo
trait Bar
implicit def subFooBar: Foo <:< Bar = null
implicit def subFooBar: Foo <:< Bar = implicitly[Foo <:< Foo].asInstanceOf[Foo <:< Bar]
// make sure the above is found
implicitly[As[Foo, Bar]]
val res: Foo <:< Bar = implicitly[As[Foo, Bar]].toPredef
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/IsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class IsSuite extends CatsSuite {
val flip: Leibniz[Bar, Bar] = lifted.flip
val lift: Leibniz[List[Bar], List[Bar]] = lifted.lift[List]
val coerce: Bar = lifted.coerce(new Bar {})
val predefEq: =:=[Bar, Bar] = lifted.predefEq
val predefEq: =:=[Bar, Bar] = lifted.toPredef

{
trait Foo
implicit def eqFooBar: Foo =:= Bar = null
implicit def eqFooBar: Foo =:= Bar = implicitly[Foo =:= Foo].asInstanceOf[Foo =:= Bar]
// make sure the above is found
implicitly[Is[Foo, Bar]]

Expand Down

0 comments on commit c2ea985

Please sign in to comment.