Open
Description
Compiler version
3.6.3-3.7.0
Minimized code
//> using scala 3.6.3
class Test {
trait Typeclass[T] extends Typeclass.Base[T]
object Typeclass {
trait Base[T]
trait Derived[T] extends Typeclass[T]
// this shouldn't be applicable to A
given [T: Base]: Typeclass[T] = null
}
trait Tag[T]
given [T]: Tag[T] = null
class A[T]
object A {
// removing Tag somehow resolves ambiguity
given [T: Tag]: Typeclass.Derived[A[T]] = null
}
summon[Typeclass[A[Int]]]
}
Output
[warn] 19 | summon[Typeclass[A[Int]]]
[warn] | ^
[warn] |Given search preference for Test.this.Typeclass[Test.this.A[Int]] between alternatives
[warn] | (Test.this.A.given_Derived_A :
[warn] | [T]
[warn] | (using evidence$1: Test.this.Tag[T]):
[warn] | Test.this.Typeclass.Derived[Test.this.A[T]]
[warn] |)
[warn] |and
[warn] | (Test.this.Typeclass.given_Typeclass_T :
[warn] | [T]
[warn] | (using evidence$1: Test.this.Typeclass.Base[T]):
[warn] | Test.this.Typeclass[T]
[warn] |)
[warn] |will change in the future release.
[warn] |Current choice : the first alternative
[warn] |Choice from Scala 3.7 : none - it's ambiguous
[warn] |
[warn] |Suppress this warning by choosing -source 3.5, -source 3.7, or
[warn] |by using @annotation.nowarn("id=205")
[warn] one warning found
Expectation
code compiles without warnings (or errors on 3.7)
looks related to #22913 but here there is no real ambiguity