Skip to content

Commit a1dc168

Browse files
committed
Replace delegate for by given as in compiler and tests.
1 parent 0227ebe commit a1dc168

File tree

67 files changed

+225
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+225
-223
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Flags {
2222

2323
type Flag = opaques.Flag
2424

25-
delegate FlagOps {
25+
given FlagOps {
2626

2727
def (x: FlagSet) bits: Long = opaques.toBits(x)
2828

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object Completion {
121121
if (buffer.mode != Mode.None) {
122122
path match {
123123
case Select(qual, _) :: _ => buffer.addMemberCompletions(qual)
124-
case Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr) // TODO: distinguish delegate from non-delegate
124+
case Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr) // TODO: distinguish given from plain imports
125125
case (_: Thicket) :: Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr)
126126
case _ => buffer.addScopeCompletions
127127
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ trait Implicits { self: Typer =>
12061206
case fail: SearchFailureType =>
12071207

12081208
def hiddenImplicitNote(s: SearchSuccess) =
1209-
em"\n\nNote: delegate ${s.ref.symbol.showLocated} was not considered because it was not imported with `import delegate`."
1209+
em"\n\nNote: given instance ${s.ref.symbol.showLocated} was not considered because it was not imported with `import given`."
12101210

12111211
def FindHiddenImplicitsCtx(ctx: Context): Context =
12121212
if (ctx == NoContext) ctx

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object ImportInfo {
2828
* @param selectors The selector clauses
2929
* @param symNameOpt Optionally, the name of the import symbol. None for root imports.
3030
* Defined for all explicit imports from ident or select nodes.
31-
* @param importGiven true if this is a delegate import
31+
* @param importGiven true if this is a given import
3232
* @param isRootImport true if this is one of the implicit imports of scala, java.lang,
3333
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
3434
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ class Namer { typer: Typer =>
949949

950950
def whyNoForwarder(mbr: SingleDenotation): String = {
951951
val sym = mbr.symbol
952-
if (sym.isOneOf(GivenOrImplicit) != exp.impliedOnly) s"is ${if (exp.impliedOnly) "not " else ""}a delegate"
952+
if (sym.isOneOf(GivenOrImplicit) != exp.impliedOnly) s"is ${if (exp.impliedOnly) "not " else ""}a given instance"
953953
else if (!sym.isAccessibleFrom(path.tpe)) "is not accessible"
954954
else if (sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge)) SKIP
955955
else if (cls.derivesFrom(sym.owner) &&

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ReplCompilerTests extends ReplTest {
129129
}
130130

131131
@Test def i5897 =
132-
fromInitialState { implicit state => run("delegate for Int = 10") }
132+
fromInitialState { implicit state => run("given as Int = 10") }
133133
.andThen { implicit state =>
134134
assertEquals(
135135
"def Int_given: Int",
@@ -151,7 +151,7 @@ class ReplCompilerTests extends ReplTest {
151151
| def (x: T) > (y: T) = compare(x, y) > 0
152152
|}
153153
|
154-
|delegate IntOrd for Ord[Int] {
154+
|given IntOrd as Ord[Int] {
155155
| def compare(x: Int, y: Int) =
156156
| if (x < y) -1 else if (x > y) +1 else 0
157157
|}

library/src/scala/Eql.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Eql {
1616
object derived extends Eql[Any, Any]
1717

1818
/** A fall-back instance to compare values of any types.
19-
* Even though this method is not declared a delegate, the compiler will
19+
* Even though this method is not declared as given, the compiler will
2020
* synthesize implicit arguments as solutions to `Eql[T, U]` queries if
2121
* the rules of multiversal equality require it.
2222
*/

library/src/scala/quoted/Liftable.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ trait Liftable[T] {
1717
*/
1818
object Liftable {
1919

20-
delegate Liftable_Boolean_delegate for Liftable[Boolean] = new PrimitiveLiftable
21-
delegate Liftable_Byte_delegate for Liftable[Byte] = new PrimitiveLiftable
22-
delegate Liftable_Short_delegate for Liftable[Short] = new PrimitiveLiftable
23-
delegate Liftable_Int_delegate for Liftable[Int] = new PrimitiveLiftable
24-
delegate Liftable_Long_delegate for Liftable[Long] = new PrimitiveLiftable
25-
delegate Liftable_Float_delegate for Liftable[Float] = new PrimitiveLiftable
26-
delegate Liftable_Double_delegate for Liftable[Double] = new PrimitiveLiftable
27-
delegate Liftable_Char_delegate for Liftable[Char] = new PrimitiveLiftable
28-
delegate Liftable_String_delegate for Liftable[String] = new PrimitiveLiftable
20+
given Liftable_Boolean_delegate as Liftable[Boolean] = new PrimitiveLiftable
21+
given Liftable_Byte_delegate as Liftable[Byte] = new PrimitiveLiftable
22+
given Liftable_Short_delegate as Liftable[Short] = new PrimitiveLiftable
23+
given Liftable_Int_delegate as Liftable[Int] = new PrimitiveLiftable
24+
given Liftable_Long_delegate as Liftable[Long] = new PrimitiveLiftable
25+
given Liftable_Float_delegate as Liftable[Float] = new PrimitiveLiftable
26+
given Liftable_Double_delegate as Liftable[Double] = new PrimitiveLiftable
27+
given Liftable_Char_delegate as Liftable[Char] = new PrimitiveLiftable
28+
given Liftable_String_delegate as Liftable[String] = new PrimitiveLiftable
2929

3030
private class PrimitiveLiftable[T <: Unit | Null | Int | Boolean | Byte | Short | Int | Long | Float | Double | Char | String] extends Liftable[T] {
3131
/** Lift a primitive value `n` into `'{ n }` */

library/src/scala/quoted/Type.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ package quoted {
1717

1818
/** Some basic type tags, currently incomplete */
1919
object Type {
20-
delegate UnitTag for Type[Unit] = new TaggedType[Unit]
21-
delegate BooleanTag for Type[Boolean] = new TaggedType[Boolean]
22-
delegate ByteTag for Type[Byte] = new TaggedType[Byte]
23-
delegate CharTag for Type[Char] = new TaggedType[Char]
24-
delegate ShortTag for Type[Short] = new TaggedType[Short]
25-
delegate IntTag for Type[Int] = new TaggedType[Int]
26-
delegate LongTag for Type[Long] = new TaggedType[Long]
27-
delegate FloatTag for Type[Float] = new TaggedType[Float]
28-
delegate DoubleTag for Type[Double] = new TaggedType[Double]
20+
given UnitTag as Type[Unit] = new TaggedType[Unit]
21+
given BooleanTag as Type[Boolean] = new TaggedType[Boolean]
22+
given ByteTag as Type[Byte] = new TaggedType[Byte]
23+
given CharTag as Type[Char] = new TaggedType[Char]
24+
given ShortTag as Type[Short] = new TaggedType[Short]
25+
given IntTag as Type[Int] = new TaggedType[Int]
26+
given LongTag as Type[Long] = new TaggedType[Long]
27+
given FloatTag as Type[Float] = new TaggedType[Float]
28+
given DoubleTag as Type[Double] = new TaggedType[Double]
2929
}
3030

3131
}

library/src/scala/tasty/reflect/TreeUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ trait TreeUtils
286286
/** Bind the `rhs` to a `val` and use it in `body` */
287287
def let(rhs: Term)(body: Ident => Term): Term = {
288288
import scala.quoted.QuoteContext
289-
delegate for QuoteContext = new QuoteContext(this)
289+
given as QuoteContext = new QuoteContext(this)
290290
type T // TODO probably it is better to use the Sealed contruct rather than let the user create their own existential type
291291
implicit val rhsTpe: quoted.Type[T] = rhs.tpe.seal.asInstanceOf[quoted.Type[T]]
292292
val rhsExpr = rhs.seal.cast[T]

0 commit comments

Comments
 (0)