Skip to content

Commit f236ce9

Browse files
committed
Revert "Switch mapping of context bounds to using clauses in 3.6"
1 parent 8f85da5 commit f236ce9

File tree

11 files changed

+32
-64
lines changed

11 files changed

+32
-64
lines changed

Diff for: compiler/src/dotty/tools/dotc/ast/Desugar.scala

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

302302
val paramssNoContextBounds =
303-
val iflag = paramss.lastOption.flatMap(_.headOption) match
304-
case Some(param) if param.mods.isOneOf(GivenOrImplicit) =>
305-
param.mods.flags & GivenOrImplicit
306-
case _ =>
307-
if Feature.sourceVersion.isAtLeast(`3.6`) then Given
308-
else Implicit
303+
val iflag = if Feature.sourceVersion.isAtLeast(`future`) then Given else Implicit
309304
val flags = if isPrimaryConstructor then iflag | LocalParamAccessor else iflag | Param
310305
mapParamss(paramss) {
311306
tparam => desugarContextBounds(tparam, evidenceParamBuf, flags, freshName, paramss)
@@ -477,14 +472,7 @@ object desugar {
477472
case ValDefs(mparams) :: _ if mparams.exists(referencesBoundName) =>
478473
params :: mparamss
479474
case ValDefs(mparams @ (mparam :: _)) :: Nil if mparam.mods.isOneOf(GivenOrImplicit) =>
480-
val normParams =
481-
if params.head.mods.flags.is(Given) != mparam.mods.flags.is(Given) then
482-
params.map: param =>
483-
val normFlags = param.mods.flags &~ GivenOrImplicit | (mparam.mods.flags & (GivenOrImplicit))
484-
param.withMods(param.mods.withFlags(normFlags))
485-
.showing(i"ADAPTED PARAM $result ${result.mods.flags} for ${meth.name}")
486-
else params
487-
(normParams ++ mparams) :: Nil
475+
(params ++ mparams) :: Nil
488476
case mparams :: mparamss1 =>
489477
mparams :: recur(mparamss1)
490478
case Nil =>

Diff for: compiler/src/dotty/tools/dotc/util/Signatures.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ object Signatures {
499499

500500
def isSyntheticEvidence(name: String) =
501501
name.startsWith(NameKinds.ContextBoundParamName.separator)
502-
&& symbol.paramSymss.flatten.find(_.name.show == name).exists(_.flags.isOneOf(Flags.GivenOrImplicit))
502+
&& symbol.paramSymss.flatten.find(_.name.show == name).exists(_.flags.is(Flags.Implicit))
503503

504504
def toTypeParam(tpe: PolyType): List[Param] =
505505
val evidenceParams = (tpe.paramNamess.flatten zip tpe.paramInfoss.flatten).flatMap:

Diff for: presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class ShortenedTypePrinter(
296296
val (methodParams, extParams) = splitExtensionParamss(gsym)
297297
val paramss = methodParams ++ extParams
298298
lazy val implicitParams: List[Symbol] =
299-
paramss.flatMap(params => params.filter(p => p.isOneOf(Flags.GivenOrImplicit)))
299+
paramss.flatMap(params => params.filter(p => p.is(Flags.Implicit)))
300300

301301
lazy val implicitEvidenceParams: Set[Symbol] =
302302
implicitParams

Diff for: scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,7 @@ trait ClassLikeSupport:
588588
// `def foo[A: ClassTag] = 1`.
589589
// Scala spec states that `$` should not be used in names and behaviour may be undefiend in such case.
590590
// Documenting method slightly different then its definition is withing the 'undefiend behaviour'.
591-
symbol.paramSymss.flatten.find(_.name == name).exists(p =>
592-
p.flags.is(Flags.Given) || p.flags.is(Flags.Implicit))
591+
symbol.paramSymss.flatten.find(_.name == name).exists(_.flags.is(Flags.Implicit))
593592

594593
def handlePolyType(memberInfo: MemberInfo, polyType: PolyType): MemberInfo =
595594
val typeParamList = MemberInfo.TypeParameterList(polyType.paramNames.zip(polyType.paramBounds).toMap)

Diff for: staging/test-resources/repl-staging/i6263

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ scala> import quoted.staging.{Compiler => StagingCompiler, _}
33
scala> implicit def compiler: StagingCompiler = StagingCompiler.make(getClass.getClassLoader)
44
def compiler: scala.quoted.staging.Compiler
55
scala> def fn[T : Type](v : T) = println("ok")
6-
def fn[T](v: T)(using evidence$1: scala.quoted.Type[T]): Unit
6+
def fn[T](v: T)(implicit evidence$1: scala.quoted.Type[T]): Unit
77
scala> withQuotes { fn("foo") }
88
ok
99
scala> withQuotes { fn((1,2)) }

Diff for: tests/neg/ctx-bounds-priority-migration.scala

-13
This file was deleted.

Diff for: tests/neg/ctx-bounds-priority.scala

-6
This file was deleted.

Diff for: 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-
| (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))
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))
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)(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]
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]
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

Diff for: 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: GIVEN
77+
67: IMPLICIT
7878
68: IDENTtpt 17 [Nothing]
7979
70: TYPEREF 17 [Nothing]
8080
72: TERMREFpkg 2 [scala]

Diff for: tests/semanticdb/metac.expect

+5-5
Original file line numberDiff line numberDiff line change
@@ -2621,9 +2621,9 @@ example/Methods#m6(+1). => method m6 (param x: List[T]): Nothing
26212621
example/Methods#m6(+1).(x) => param x: List[T]
26222622
example/Methods#m6(+2). => method m6 (param x: List[T]): Nothing
26232623
example/Methods#m6(+2).(x) => param x: List[T]
2624-
example/Methods#m7(). => method m7 [typeparam U ](param c: Methods[T], param l: List[U])(implicit given param evidence$1: Ordering[U]): Nothing
2624+
example/Methods#m7(). => method m7 [typeparam U ](param c: Methods[T], param l: List[U])(implicit param evidence$1: Ordering[U]): Nothing
26252625
example/Methods#m7().(c) => param c: Methods[T]
2626-
example/Methods#m7().(evidence$1) => implicit given param evidence$1: Ordering[U]
2626+
example/Methods#m7().(evidence$1) => implicit param evidence$1: Ordering[U]
26272627
example/Methods#m7().(l) => param l: List[U]
26282628
example/Methods#m7().[U] => typeparam U
26292629
example/Methods#m9(). => method m9 (param x: m9().): Nothing
@@ -3553,10 +3553,10 @@ example/Synthetic#F# => class F extends Object { self: F => +1 decls }
35533553
example/Synthetic#F#`<init>`(). => primary ctor <init> (): F
35543554
example/Synthetic#J# => class J [typeparam T ] extends Object { self: J[T] => +4 decls }
35553555
example/Synthetic#J#[T] => typeparam T
3556-
example/Synthetic#J#`<init>`(). => primary ctor <init> [typeparam T ](implicit given param evidence$1: Manifest[T])(): J[T]
3557-
example/Synthetic#J#`<init>`().(evidence$1) => implicit given param evidence$1: Manifest[T]
3556+
example/Synthetic#J#`<init>`(). => primary ctor <init> [typeparam T ]()(implicit param evidence$1: Manifest[T]): J[T]
3557+
example/Synthetic#J#`<init>`().(evidence$1) => implicit param evidence$1: Manifest[T]
35583558
example/Synthetic#J#arr. => val method arr Array[T]
3559-
example/Synthetic#J#evidence$1. => private[this] implicit val given method evidence$1 Manifest[T]
3559+
example/Synthetic#J#evidence$1. => private[this] implicit val method evidence$1 Manifest[T]
35603560
example/Synthetic#Name. => val method Name Regex
35613561
example/Synthetic#`<init>`(). => primary ctor <init> (): Synthetic
35623562
example/Synthetic#a1. => val method a1 Int

0 commit comments

Comments
 (0)