"=:=" does not work as expected, why?

I want to the following code to prove “A is not B”:

trait IsNot[A, B]

object IsNot:
  given xorA[A, B]: IsNot[A, B] with {}
  given xorB[A, B](using proof: A =:= B): IsNot[A, B] with {}

But the following code pass the compilation:

summon[IsNot[Int, Int]]

I thought the compiler should complain it with “Ambiguous given instances”.

What is wrong with my above code?

Thanks for your help!

Guofeng

See changes to implicit resolution.

#7 says the using parameter is a tie-breaker by making that alternative less specific.

Also #4 describes NotGiven.

I guess the “live” version on the site is this link for the reference. That is under the section for “Returning Users”. I will never find it again, and when I want to, I will not find this reply with my directions.

2 Likes