Skip to content

Commit ba82d69

Browse files
committed
Switch mapping of context bounds to using clauses in 3.6
Was future before.
1 parent 0cf25db commit ba82d69

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ object desugar {
300300
// implicit resolution in Scala 3.
301301

302302
val paramssNoContextBounds =
303-
val iflag = if Feature.sourceVersion.isAtLeast(`future`) then Given else Implicit
303+
val iflag = if Feature.sourceVersion.isAtLeast(`3.6`) then Given else Implicit
304304
val flags = if isPrimaryConstructor then iflag | LocalParamAccessor else iflag | Param
305305
mapParamss(paramss) {
306306
tparam => desugarContextBounds(tparam, evidenceParamBuf, flags, freshName, paramss)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//> using options -source 3.5
2+
trait Eq[A]
3+
trait Order[A] extends Eq[A]:
4+
def toOrdering: Ordering[A]
5+
6+
def f[Element: Eq: Order] = summon[Eq[Element]].toOrdering // ok
7+
8+
def Test() =
9+
val eq: Eq[Int] = ???
10+
val ord: Order[Int] = ???
11+
f(eq, ord) // error
12+
f(using eq, ord) // ok
13+

tests/neg/ctx-bounds-priority.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//> using options -source 3.6
2+
trait Eq[A]
3+
trait Order[A] extends Eq[A]:
4+
def toOrdering: Ordering[A]
5+
6+
def Test[Element: Eq: Order] = summon[Eq[Element]].toOrdering // error

tests/neg/i10901.check

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
-- [E008] Not Found Error: tests/neg/i10901.scala:45:38 ----------------------------------------------------------------
22
45 | val pos1: Point2D[Int,Double] = x º y // error
33
| ^^^
4-
| value º is not a member of object BugExp4Point2D.IntT.
5-
| An extension method was tried, but could not be fully constructed:
6-
|
7-
| º(x)
8-
|
9-
| failed with:
10-
|
11-
| Ambiguous overload. The overloaded alternatives of method º in object dsl with types
12-
| [T1, T2]
13-
| (x: BugExp4Point2D.ColumnType[T1])
14-
| (y: BugExp4Point2D.ColumnType[T2])
15-
| (implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
16-
| [T1, T2]
17-
| (x: T1)
18-
| (y: BugExp4Point2D.ColumnType[T2])
19-
| (implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
20-
| both match arguments ((x : BugExp4Point2D.IntT.type))((y : BugExp4Point2D.DoubleT.type))
4+
| value º is not a member of object BugExp4Point2D.IntT.
5+
| An extension method was tried, but could not be fully constructed:
6+
|
7+
| º(x)
8+
|
9+
| failed with:
10+
|
11+
| Ambiguous overload. The overloaded alternatives of method º in object dsl with types
12+
| [T1, T2]
13+
| (x: BugExp4Point2D.ColumnType[T1])
14+
| (y: BugExp4Point2D.ColumnType[T2])
15+
| (using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
16+
| [T1, T2]
17+
| (x: T1)
18+
| (y: BugExp4Point2D.ColumnType[T2])
19+
| (using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
20+
| both match arguments ((x : BugExp4Point2D.IntT.type))((y : BugExp4Point2D.DoubleT.type))
2121
-- [E008] Not Found Error: tests/neg/i10901.scala:48:38 ----------------------------------------------------------------
2222
48 | val pos4: Point2D[Int,Double] = x º 201.1 // error
2323
| ^^^
@@ -31,8 +31,8 @@
3131
| Ambiguous overload. The overloaded alternatives of method º in object dsl with types
3232
| [T1, T2]
3333
| (x: BugExp4Point2D.ColumnType[T1])
34-
| (y: T2)(implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
35-
| [T1, T2](x: T1)(y: T2)(implicit evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
34+
| (y: T2)(using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
35+
| [T1, T2](x: T1)(y: T2)(using evidence$1: Numeric[T1], evidence$2: Numeric[T2]): BugExp4Point2D.Point2D[T1, T2]
3636
| both match arguments ((x : BugExp4Point2D.IntT.type))((201.1d : Double))
3737
-- [E008] Not Found Error: tests/neg/i10901.scala:62:16 ----------------------------------------------------------------
3838
62 | val y = "abc".foo // error

tests/pos/i20901/Foo.tastycheck

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Trees (98 bytes, starting from <elided base index>):
7474
61: SHAREDtype 6
7575
63: IDENTtpt 16 [T]
7676
65: TYPEREFdirect 39
77-
67: IMPLICIT
77+
67: GIVEN
7878
68: IDENTtpt 17 [Nothing]
7979
70: TYPEREF 17 [Nothing]
8080
72: TERMREFpkg 2 [scala]

0 commit comments

Comments
 (0)