diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index c360712999e2..785dac9b4658 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -300,7 +300,7 @@ object desugar { // implicit resolution in Scala 3. val paramssNoContextBounds = - val iflag = if Feature.sourceVersion.isAtLeast(`future`) then Given else Implicit + val iflag = if Feature.sourceVersion.isAtLeast(`3.6`) then Given else Implicit val flags = if isPrimaryConstructor then iflag | LocalParamAccessor else iflag | Param mapParamss(paramss) { tparam => desugarContextBounds(tparam, evidenceParamBuf, flags, freshName, paramss) diff --git a/tests/neg/ctx-bounds-priority-migration.scala b/tests/neg/ctx-bounds-priority-migration.scala new file mode 100644 index 000000000000..8fc819c1e089 --- /dev/null +++ b/tests/neg/ctx-bounds-priority-migration.scala @@ -0,0 +1,13 @@ +//> using options -source 3.5 +trait Eq[A] +trait Order[A] extends Eq[A]: + def toOrdering: Ordering[A] + +def f[Element: Eq: Order] = summon[Eq[Element]].toOrdering // ok + +def Test() = + val eq: Eq[Int] = ??? + val ord: Order[Int] = ??? + f(eq, ord) // error + f(using eq, ord) // ok + diff --git a/tests/neg/ctx-bounds-priority.scala b/tests/neg/ctx-bounds-priority.scala new file mode 100644 index 000000000000..6594642d67c3 --- /dev/null +++ b/tests/neg/ctx-bounds-priority.scala @@ -0,0 +1,6 @@ +//> using options -source 3.6 +trait Eq[A] +trait Order[A] extends Eq[A]: + def toOrdering: Ordering[A] + +def Test[Element: Eq: Order] = summon[Eq[Element]].toOrdering // error diff --git a/tests/neg/i10901.check b/tests/neg/i10901.check index 4a8fa5db28bf..325cdccc6aab 100644 --- a/tests/neg/i10901.check +++ b/tests/neg/i10901.check @@ -1,23 +1,23 @@ -- [E008] Not Found Error: tests/neg/i10901.scala:45:38 ---------------------------------------------------------------- 45 | val pos1: Point2D[Int,Double] = x º y // error | ^^^ - | value º is not a member of object BugExp4Point2D.IntT. - | An extension method was tried, but could not be fully constructed: - | - | º(x) - | - | failed with: - | - | Ambiguous overload. The overloaded alternatives of method º in object dsl with types - | [T1, T2] - | (x: BugExp4Point2D.ColumnType[T1]) - | (y: BugExp4Point2D.ColumnType[T2]) - | (implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] - | [T1, T2] - | (x: T1) - | (y: BugExp4Point2D.ColumnType[T2]) - | (implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] - | both match arguments ((x : BugExp4Point2D.IntT.type))((y : BugExp4Point2D.DoubleT.type)) + | value º is not a member of object BugExp4Point2D.IntT. + | An extension method was tried, but could not be fully constructed: + | + | º(x) + | + | failed with: + | + | Ambiguous overload. The overloaded alternatives of method º in object dsl with types + | [T1, T2] + | (x: BugExp4Point2D.ColumnType[T1]) + | (y: BugExp4Point2D.ColumnType[T2]) + | (using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] + | [T1, T2] + | (x: T1) + | (y: BugExp4Point2D.ColumnType[T2]) + | (using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] + | both match arguments ((x : BugExp4Point2D.IntT.type))((y : BugExp4Point2D.DoubleT.type)) -- [E008] Not Found Error: tests/neg/i10901.scala:48:38 ---------------------------------------------------------------- 48 | val pos4: Point2D[Int,Double] = x º 201.1 // error | ^^^ @@ -31,8 +31,8 @@ | Ambiguous overload. The overloaded alternatives of method º in object dsl with types | [T1, T2] | (x: BugExp4Point2D.ColumnType[T1]) - | (y: T2)(implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] - | [T1, T2](x: T1)(y: T2)(implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] + | (y: T2)(using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] + | [T1, T2](x: T1)(y: T2)(using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2] | both match arguments ((x : BugExp4Point2D.IntT.type))((201.1d : Double)) -- [E008] Not Found Error: tests/neg/i10901.scala:62:16 ---------------------------------------------------------------- 62 | val y = "abc".foo // error diff --git a/tests/pos/i20901/Foo.tastycheck b/tests/pos/i20901/Foo.tastycheck index 565c5c793bad..583595a7eb0a 100644 --- a/tests/pos/i20901/Foo.tastycheck +++ b/tests/pos/i20901/Foo.tastycheck @@ -74,7 +74,7 @@ Trees (98 bytes, starting from ): 61: SHAREDtype 6 63: IDENTtpt 16 [T] 65: TYPEREFdirect 39 - 67: IMPLICIT + 67: GIVEN 68: IDENTtpt 17 [Nothing] 70: TYPEREF 17 [Nothing] 72: TERMREFpkg 2 [scala]