Skip to content

Commit 7d559ad

Browse files
authored
Treat 3.5-migration the same as 3.5 for a warning (#20436)
Treat 3.5-migration the same as 3.5 for a warning about implicit priority change Fixes #20420
2 parents 5c761fd + 8132288 commit 7d559ad

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1311,14 +1311,14 @@ trait Implicits:
13111311
else
13121312
var cmp = comp(using searchContext())
13131313
val sv = Feature.sourceVersion
1314-
if sv == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
1314+
if sv.stable == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration` then
13151315
val prev = comp(using searchContext().addMode(Mode.OldImplicitResolution))
13161316
if cmp != prev then
13171317
def choice(c: Int) = c match
13181318
case -1 => "the second alternative"
13191319
case 1 => "the first alternative"
13201320
case _ => "none - it's ambiguous"
1321-
if sv == SourceVersion.`3.5` then
1321+
if sv.stable == SourceVersion.`3.5` then
13221322
report.warning(
13231323
em"""Given search preference for $pt between alternatives ${alt1.ref} and ${alt2.ref} will change
13241324
|Current choice : ${choice(prev)}

tests/warn/i20420.scala

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//> using options -source 3.5-migration
2+
3+
final class StrictEqual[V]
4+
final class Less[V]
5+
type LessEqual[V] = Less[V] | StrictEqual[V]
6+
7+
object TapirCodecIron:
8+
trait ValidatorForPredicate[Value, Predicate]
9+
trait PrimitiveValidatorForPredicate[Value, Predicate]
10+
extends ValidatorForPredicate[Value, Predicate]
11+
12+
given validatorForLessEqual[N: Numeric, NM <: N](using
13+
ValueOf[NM]
14+
): PrimitiveValidatorForPredicate[N, LessEqual[NM]] = ???
15+
given validatorForDescribedOr[N, P](using
16+
IsDescription[P]
17+
): ValidatorForPredicate[N, P] = ???
18+
19+
trait IsDescription[A]
20+
object IsDescription:
21+
given derived[A]: IsDescription[A] = ???
22+
23+
@main def Test = {
24+
import TapirCodecIron.{*, given}
25+
type IntConstraint = LessEqual[3]
26+
summon[ValidatorForPredicate[Int, IntConstraint]] // warn
27+
}

0 commit comments

Comments
 (0)