Skip to content

Commit fab6cbc

Browse files
committed
Change more files to new syntax
1 parent fb91e30 commit fab6cbc

File tree

15 files changed

+26
-25
lines changed

15 files changed

+26
-25
lines changed

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ object Scala3 with
212212
// end RangeOps
213213

214214
/** Sort symbol occurrences by their start position. */
215-
given OccurrenceOrdering: Ordering[SymbolOccurrence] = (x, y) =>
215+
given OccurrenceOrdering as Ordering[SymbolOccurrence] = (x, y) =>
216216
x.range -> y.range match
217217
case None -> _ | _ -> None => 0
218218
case Some(a) -> Some(b) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ class Typer extends Namer
13021302
}
13031303

13041304
def typedWhileDo(tree: untpd.WhileDo)(implicit ctx: Context): Tree = {
1305-
given whileCtx: Context = Nullables.whileContext(tree.span)(using ctx)
1305+
given whileCtx as Context = Nullables.whileContext(tree.span)(using ctx)
13061306
val cond1 =
13071307
if (tree.cond eq EmptyTree) EmptyTree
13081308
else typed(tree.cond, defn.BooleanType)

tests/neg/i5978.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ object TextParser {
1111
as Conversion[Char, Position[CharSequence]] = ???
1212
}
1313

14-
1514
object Testcase {
1615
def main(args: Array[String]): Unit = {
1716
import TextParser._

tests/neg/i7078.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
trait A
22
class B extends A
33

4-
given g1 as _ <: A = B() // error: `<:' is only allowed for given with `inline' modifier // error
5-
6-
inline given g2 as _ <: A // error: <: A is not a class type
7-
def foo = 2 // error: `=' expected
4+
given g1 as _ <: A = B() // error: `_ <:' is only allowed for given with `inline' modifier // error
85

6+
inline given g2 as _ <: A: // error: `=' expected
7+
def foo = 2
8+
// error

tests/pos-custom-args/erased/i7868.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ object Coproduct {
1111

1212
object At {
1313

14-
given atHead[Head, Tail]: At[Head +: Tail, Head, 0] {
14+
given atHead[Head, Tail] as At[Head +: Tail, Head, 0] {
1515
def cast: Head <:< Head +: Tail = summon[Head <:< Head +: Tail]
1616
}
1717

18-
given atTail[Head, Tail, Value, NextIndex <: Int](using atNext: At[Tail, Value, NextIndex]) as At[Head +: Tail, Value, S[NextIndex]] {
18+
given atTail[Head, Tail, Value, NextIndex <: Int]
19+
(using atNext: At[Tail, Value, NextIndex])
20+
as At[Head +: Tail, Value, S[NextIndex]]:
1921
val cast: Value <:< Head +: Tail = atNext.cast
20-
}
2122

2223
given [A](using A) as (() => A)= { () => summon[A]}
2324
}

tests/pos-custom-args/erased/i7878.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ object Boom {
22
import scala.compiletime._
33
trait Fail[A <: Int, B <: Int]
44

5-
erased inline given fail[X <: Int, Y <: Int]: Fail[X, Y] = {
5+
erased inline given fail[X <: Int, Y <: Int] as Fail[X, Y] = {
66
scala.compiletime.summonFrom {
77
case t: Fail[X, y] if constValue[y] < constValue[Y] => ???
88
}

tests/pos/combine.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ trait Semigroup[A] {
22
def (x: A).combine(y: A): A
33
}
44
given Semigroup[Int] = ???
5-
given [A, B](using Semigroup[A], Semigroup[B]): Semigroup[(A, B)] = ???
5+
given [A, B](using Semigroup[A], Semigroup[B]) as Semigroup[(A, B)] = ???
66
object Test extends App {
77
((1, 1)) combine ((2, 2)) // doesn't compile
88
((1, 1): (Int, Int)) combine (2, 2) // compiles

tests/pos/i7851.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ object Wrapper { type Aux[T <: Tuple, WrappedT0 <: Tuple] = Wrapper[T] { type Wr
88

99
given Wrapper[Unit] { type WrappedT = Unit }
1010

11-
given [T: Wrappable]: Wrapper[T] { type WrappedT = Wrapped[T] }
11+
given [T: Wrappable] as Wrapper[T] { type WrappedT = Wrapped[T] }
1212

13-
given [H: Wrappable, T <: Tuple, WrappedT0 <: Tuple](using Wrapper.Aux[T, WrappedT0]): Wrapper[H *: T] {
13+
given [H: Wrappable, T <: Tuple, WrappedT0 <: Tuple]
14+
(using Wrapper.Aux[T, WrappedT0])
15+
as Wrapper[H *: T]:
1416
type WrappedT = Wrapped[H] *: WrappedT0
15-
}
1617

1718
def wrappedFunction[F, FArgs <: Tuple, WrapperFArgs <: Tuple, R: Wrappable](
1819
function: F

tests/pos/i8198.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ trait Eq[A] {
55

66
case class Id[T](id: T)
77

8-
given idEq[A](using eqA: Eq[A]): Eq[Id[A]] = new {
8+
given idEq[A](using eqA: Eq[A]) as Eq[Id[A]] = new {
99
def (i1: Id[A]) === (i2: Id[A]) = !(i1.id /== i2.id)
1010
}

tests/pos/multi-given.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def foo(implicit a: A, b: B, c: C) = "foo"
77

88
given A, B {}
99

10-
given ops: A with B {}
10+
given ops as A with B {}

tests/run-macros/i6988/FirstArg_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package foo
22

33
case class FirstArg(value: Any, source: String)
44
object FirstArg {
5-
inline given create: FirstArg = ${Macros.argsImpl}
5+
inline given create as FirstArg = ${Macros.argsImpl}
66
}
77

88
object Macros {

tests/run-macros/i8007/Macro_3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object Eq {
3232
case '[Unit] => Nil
3333
}
3434

35-
given derived[T: Type](using qctx: QuoteContext): Expr[Eq[T]] = {
35+
given derived[T: Type](using qctx: QuoteContext) as Expr[Eq[T]] = {
3636
import qctx.tasty.{_, given}
3737

3838
val ev: Expr[Mirror.Of[T]] = summonExpr(using '[Mirror.Of[T]]).get

tests/semanticdb/expect/Givens.expect.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ object Givens/*<-a::b::Givens.*/:
2222
/*<-a::b::Givens.given_Monoid_String.*//*->a::b::Givens.Monoid#*//*->scala::Predef.String#*/ def empty/*<-a::b::Givens.given_Monoid_String.empty().*/ = ""
2323
def (x: Str/*<-a::b::Givens.given_Monoid_String.combine().*//*<-a::b::Givens.given_Monoid_String.combine().(x)*/ing/*->scala::Predef.String#*/).combine(y/*<-a::b::Givens.given_Monoid_String.combine().(y)*/: String/*->scala::Predef.String#*/) = x/*->a::b::Givens.given_Monoid_String.combine().(x)*/ +/*->java::lang::String#`+`().*/ y/*->a::b::Givens.given_Monoid_String.combine().(y)*/
2424

25-
inline given int2String/*<-a::b::Givens.int2String().*/: Conversion/*->scala::Conversion#*/[Int/*->scala::Int#*/, String/*->scala::Predef.String#*/] = _.toString/*->scala::Any#toString().*/
25+
inline given int2String/*<-a::b::Givens.int2String().*/ as Conversion/*->scala::Conversion#*/[Int/*->scala::Int#*/, String/*->scala::Predef.String#*/] = _.toString/*->scala::Any#toString().*/
2626

2727
def foo/*<-a::b::Givens.foo().*/[A/*<-a::b::Givens.foo().[A]*/](using A/*<-a::b::Givens.foo().(A)*/: Monoid/*->a::b::Givens.Monoid#*/[A/*->a::b::Givens.foo().[A]*/]): A/*->a::b::Givens.foo().[A]*/ = A/*->a::b::Givens.foo().(A)*/.combine/*->a::b::Givens.Monoid#combine().*/(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/)(A/*->a::b::Givens.foo().(A)*/.empty/*->a::b::Givens.Monoid#empty().*/)

tests/semanticdb/expect/Givens.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ object Givens:
2222
def empty = ""
2323
def (x: String).combine(y: String) = x + y
2424

25-
inline given int2String: Conversion[Int, String] = _.toString
25+
inline given int2String as Conversion[Int, String] = _.toString
2626

2727
def foo[A](using A: Monoid[A]): A = A.combine(A.empty)(A.empty)

tests/semanticdb/metac.expect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,10 +1361,10 @@ Occurrences:
13611361
[22:43..22:44): + -> java/lang/String#`+`().
13621362
[22:45..22:46): y -> a/b/Givens.given_Monoid_String.combine().(y)
13631363
[24:15..24:25): int2String <- a/b/Givens.int2String().
1364-
[24:27..24:37): Conversion -> scala/Conversion#
1365-
[24:38..24:41): Int -> scala/Int#
1366-
[24:43..24:49): String -> scala/Predef.String#
1367-
[24:55..24:63): toString -> scala/Any#toString().
1364+
[24:29..24:39): Conversion -> scala/Conversion#
1365+
[24:40..24:43): Int -> scala/Int#
1366+
[24:45..24:51): String -> scala/Predef.String#
1367+
[24:57..24:65): toString -> scala/Any#toString().
13681368
[26:6..26:9): foo <- a/b/Givens.foo().
13691369
[26:10..26:11): A <- a/b/Givens.foo().[A]
13701370
[26:19..26:20): A <- a/b/Givens.foo().(A)

0 commit comments

Comments
 (0)