Skip to content

Treat 3.5-migration the same as 3.5 for a warning #20436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1311,14 +1311,14 @@ trait Implicits:
else
var cmp = comp(using searchContext())
val sv = Feature.sourceVersion
if sv == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
if sv.stable == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
if cmp != prev then
def choice(c: Int) = c match
case -1 => "the second alternative"
case 1 => "the first alternative"
case _ => "none - it's ambiguous"
if sv == SourceVersion.`3.5` then
if sv.stable == SourceVersion.`3.5` then
report.warning(
em"""Given search preference for $pt between alternatives ${alt1.ref} and ${alt2.ref} will change
|Current choice : ${choice(prev)}
Expand Down
27 changes: 27 additions & 0 deletions tests/warn/i20420.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//> using options -source 3.5-migration

final class StrictEqual[V]
final class Less[V]
type LessEqual[V] = Less[V] | StrictEqual[V]

object TapirCodecIron:
trait ValidatorForPredicate[Value, Predicate]
trait PrimitiveValidatorForPredicate[Value, Predicate]
extends ValidatorForPredicate[Value, Predicate]

given validatorForLessEqual[N: Numeric, NM <: N](using
ValueOf[NM]
): PrimitiveValidatorForPredicate[N, LessEqual[NM]] = ???
given validatorForDescribedOr[N, P](using
IsDescription[P]
): ValidatorForPredicate[N, P] = ???

trait IsDescription[A]
object IsDescription:
given derived[A]: IsDescription[A] = ???

@main def Test = {
import TapirCodecIron.{*, given}
type IntConstraint = LessEqual[3]
summon[ValidatorForPredicate[Int, IntConstraint]] // warn
}