Description
Extracted from discussion in #21226 introducing problems
@EugeneFlesselle this now causes a warning under -source:3.5 (so also in 3.5.x backports) in https://github.com/scala/scala3/blob/a64c2956f83f8dc53c0bfd7707df4a6e27cd0796/tests/pos/not-looping-implicit.scala
I wonder if this change might be more invasive than expected
-- Warning: /Users/wmazur/projects/sandbox/src/main/scala/test.scala:49:59 -----
49 | implicit lazy val inputValueSchema: Schema[InputValue] = Schema.gen
| ^^^^^^^^^^
|Given search preference for Schema[List[InputValue]] between alternatives (Schema.gen : [A]: Schema[A]) and (Schema.listSchema : [A](implicit ev: Schema[A]): Schema[List[A]]) will change
|Current choice : the second alternative
|New choice from Scala 3.6: the first alternative
|----------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
23 | val builder = summonInline[Schema[t]].asInstanceOf[Schema[Any]]
| ^^^^^^^^^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
34 | lazy val fields = recurse[m.MirroredElemLabels, m.MirroredElemTypes]()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
38 | inline given gen[A]: Schema[A] = derived[A]
| ^^^^^^^^^^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
23 | val builder = summonInline[Schema[t]].asInstanceOf[Schema[Any]]
| ^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
31 | lazy val members = recurse[m.MirroredElemLabels, m.MirroredElemTypes]()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from test.scala:23
38 | inline given gen[A]: Schema[A] = derived[A]
| ^^^^^^^^^^
----------------------------------------------------------------------------
I'll start the OpenCB to check it on the bigger number of codebases
Originally posted by @WojciechMazur in #21226 (comment)
This should not warn. The logic is wrong here. We should always prefer givens over implicits. The current logic makes implicits more general than givens, which means they will be chosen because we now prefer more general. It should probably be the reverse; we should make implicits more specific than givens.
EDIT: If we don't want to put this under a version flag (which would be cumbersome), we need to link in the choice with
preferGeneral
. Make implicits more specific than givens iff preferGeneral is true.
Originally posted by @odersky in #21226 (comment)