Skip to content

Commit 898e45f

Browse files
committed
Change name generation scheme for anonymous givens.
Instead of `T_given` it's now `given_T`. Reason: we want to follow the convention that these names start with a lowercase letter.
1 parent 57d5b21 commit 898e45f

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ object desugar {
933933

934934
/** Invent a name for an anonympus given of type or template `impl`. */
935935
def inventGivenName(impl: Tree)(implicit ctx: Context): SimpleName =
936-
avoidIllegalChars(s"${inventName(impl)}_given".toTermName.asSimpleName)
936+
avoidIllegalChars(s"given_${inventName(impl)}".toTermName.asSimpleName)
937937

938938
/** The normalized name of `mdef`. This means
939939
* 1. Check that the name does not redefine a Scala core class.

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class ReplCompilerTests extends ReplTest {
132132
fromInitialState { implicit state => run("given as Int = 10") }
133133
.andThen { implicit state =>
134134
assertEquals(
135-
"def Int_given: Int",
135+
"def given_Int: Int",
136136
storedOutput().trim
137137
)
138138
run("implicitly[Int]")

docs/docs/reference/contextual-new/relationship-implicits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Given instances can be mapped to combinations of implicit objects, classes and i
4343
would map to
4444
```scala
4545
final implicit lazy val global: ExecutionContext = new ForkJoinContext()
46-
final implicit def Context_given = ctx
46+
final implicit def given_Context = ctx
4747
```
4848

4949
### Anonymous Given Instances

tests/pos/reference/delegates.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ object Implicits extends Common {
226226
}
227227
implicit def ListOrd[T: Ord]: Ord[List[T]] = new ListOrd[T]
228228

229-
class Convertible_List_List_given[From, To](implicit c: Convertible[From, To])
229+
class given_Convertible_List_List[From, To](implicit c: Convertible[From, To])
230230
extends Convertible[List[From], List[To]] {
231231
def (x: List[From]) convert: List[To] = x.map(c.convert)
232232
}
233-
implicit def Convertible_List_List_given[From, To](implicit c: Convertible[From, To])
233+
implicit def given_Convertible_List_List[From, To](implicit c: Convertible[From, To])
234234
: Convertible[List[From], List[To]] =
235-
new Convertible_List_List_given[From, To]
235+
new given_Convertible_List_List[From, To]
236236

237237
def maximum[T](xs: List[T])
238238
(implicit cmp: Ord[T]): T =

0 commit comments

Comments
 (0)