Skip to content

Commit 0dadecc

Browse files
committed
Prototype InlineConversion as well.
Also: Move test to run
1 parent 3fb949c commit 0dadecc

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

tests/pos/inline-conversion.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
abstract class InlineConversion[-From, +To]:
2+
inline def applyInline(inline x: From): To
3+
extension (x: From) inline def convertInline: To = applyInline(x)
4+
5+
abstract class Conversion[-From, +To] extends InlineConversion[From, To]:
6+
def apply(x: From): To
7+
8+
inline def applyInline(inline x: From): To = apply(x)
9+
10+
extension (x: From) def convert: To = apply(x)
11+

tests/pos/seqlits.check

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/run/seqlits.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
last was evaluated
2+
last was evaluated
3+
Seq Vector(1, 2, 3, 4)
4+
Vector Vector(1, 2, 3, 4)
5+
last was evaluated
6+
Task with elems List(1, 2, 3, 4)
7+
last was evaluated
8+
last was evaluated
9+
Seq Vector(1, 2, 3, 4)
10+
Vector Vector(1, 2, 3, 4)
11+
last was evaluated
12+
Task with elems List(1, 2, 3, 4)

tests/pos/seqlits.scala renamed to tests/run/seqlits.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ object SeqLits:
1717
inline def seqLit[T: ClassTag, C](inline xs: T*)(using inline f: FromArray[T, C]): C =
1818
f.fromArray(IArray(xs*))
1919

20+
inline def seqLit2[T, C](inline xs: IArray[T])(using inline f: FromArray[T, C]): C =
21+
f.fromArray(xs)
22+
2023
/** Straightfoward mapping to Seq */
2124
given [T] => FromArray[T, Seq[T]]:
2225
inline def fromArray(inline xs: IArray[T]) = Seq(xs*)
@@ -31,11 +34,17 @@ object SeqLits:
3134

3235
def last: Int = { println("last was evaluated"); 4 }
3336

34-
val s: Seq[Int] = seqLit(1, 2, 3, last)
35-
val v: Vector[Int] = seqLit(1, 2, 3, last)
36-
val t: Task[Seq[Int]] = seqLit(1, 2, 3, last)
37-
3837
@main def Test =
38+
val s: Seq[Int] = seqLit(1, 2, 3, last)
39+
val v: Vector[Int] = seqLit(1, 2, 3, last)
40+
val t: Task[Seq[Int]] = seqLit(1, 2, 3, last)
3941
println(s"Seq $s")
4042
println(s"Vector $v")
4143
println(s"${t.getClass.getSimpleName} with elems ${t.body()}")
44+
45+
val s2: Seq[Int] = seqLit2(IArray(1, 2, 3, last))
46+
val v2: Vector[Int] = seqLit2(IArray(1, 2, 3, last))
47+
val t2: Task[Seq[Int]] = seqLit2(IArray(1, 2, 3, last))
48+
println(s"Seq $s2")
49+
println(s"Vector $v2")
50+
println(s"${t2.getClass.getSimpleName} with elems ${t2.body()}")

0 commit comments

Comments
 (0)