Skip to content

Commit cdb14ce

Browse files
committed
Cleanup and Fix test files
1 parent 7b3498d commit cdb14ce

10 files changed

+79
-216
lines changed

tests/pos/_typeInterweaving/ba.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11

2-
given String = ""
3-
given Double = 0
42

5-
def ba[B][A](x: A)(using B): B = summon[B]
3+
object BA {
4+
given String = ""
5+
given Double = 0
66

7-
def test =
8-
ba[String](0)
7+
def ba[B][A](x: A)(using B): B = summon[B]
8+
9+
def test = ba[String](0)
10+
11+
}
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
object chainedParams{
12

2-
class Chain{
3-
type Tail <: Chain
4-
}
3+
trait Chain{
4+
type Tail <: Chain
5+
}
6+
7+
def f[C1 <: Chain](c1: C1)[C2 <: c1.Tail](c2: C2)[C3 <: c2.Tail](c3: C3): c3.Tail = ???
8+
9+
val self = new Chain{ type Tail = this.type }
10+
val res: self.type = f(self)(self)(self)
511

6-
def f[C1 <: Chain](c1: C1)[C2 <: c1.Tail](c2: C2)[C3 <: c2.Tail](c3: C3): c3.Tail = ???
12+
type C <: Chain
13+
14+
val c3 = new Chain{ type Tail = C }
15+
val c2 = new Chain{ type Tail = c3.type }
16+
val c1 = new Chain{ type Tail = c2.type }
17+
val u: C = f(c1)(c2)(c3)
18+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
def f1[T][U](x: T, y: U): (T, U) = (x, y)
22
def f2[T](x: T)[U](y: U): (T, U) = (x, y)
3-
4-
@main def test = f2(0)[String]("Hello")
3+
def f3[T, U][V](x: T): U = ???
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
//taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html
2-
//at version 3.1.1-RC1-bin-20210930-01f040b-NIGHTLY
3-
//modified to have type currying
4-
trait Functor[F[_]]:
5-
def map[A][B](x: F[A], f: A => B): F[B]
1+
object functorCurrying:
2+
//taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html
3+
//at version 3.1.1-RC1-bin-20210930-01f040b-NIGHTLY
4+
//modified to have type currying
5+
trait Functor[F[_]]:
6+
def map[A][B](x: F[A], f: A => B): F[B]
67

78

8-
given Functor[List] with
9-
def map[A][B](x: List[A], f: A => B): List[B] =
10-
x.map(f)
9+
given Functor[List] with
10+
def map[A][B](x: List[A], f: A => B): List[B] =
11+
x.map(f)
1112

12-
def assertTransformation[F[_]: Functor][A][B](expected: F[B], original: F[A], mapping: A => B): Unit =
13-
assert(expected == summon[Functor[F]].map(original, mapping))
13+
def assertTransformation[F[_]: Functor][A][B](expected: F[B], original: F[A], mapping: A => B): Unit =
14+
assert(expected == summon[Functor[F]].map(original, mapping))
1415

15-
@main def test =
16-
assertTransformation(List("a1", "b1"), List("a", "b"), elt => s"${elt}1")
16+
@main def test =
17+
assertTransformation(List("a1", "b1"), List("a", "b"), elt => s"${elt}1")
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
//taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html
2-
//at version 3.1.1-RC1-bin-20210930-01f040b-NIGHTLY
3-
//modified to have type interveawing
4-
trait Functor[F[_]]:
5-
def map[A](x: F[A])[B](f: A => B): F[B]
1+
object functorInterweaving:
2+
//taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html
3+
//at version 3.1.1-RC1-bin-20210930-01f040b-NIGHTLY
4+
//modified to have type interveawing
5+
trait Functor[F[_]]:
6+
def map[A](x: F[A])[B](f: A => B): F[B]
67

78

8-
given Functor[List] with
9-
def map[A](x: List[A])[B](f: A => B): List[B] =
10-
x.map(f)
9+
given Functor[List] with
10+
def map[A](x: List[A])[B](f: A => B): List[B] =
11+
x.map(f)
1112

12-
def assertTransformation[F[_]: Functor][A](original: F[A])[B](expected: F[B])(mapping: A => B): Unit =
13-
assert(expected == summon[Functor[F]].map(original)(mapping))
13+
def assertTransformation[F[_]: Functor][A](original: F[A])[B](expected: F[B])(mapping: A => B): Unit =
14+
assert(expected == summon[Functor[F]].map(original)(mapping))
1415

15-
@main def test =
16-
assertTransformation(List("a", "b"))(List("a1", "b1")){elt => s"${elt}1"}
16+
@main def test =
17+
assertTransformation(List("a", "b"))(List("a1", "b1")){elt => s"${elt}1"}

tests/pos/_typeInterweaving/higherKindedReturn.scala

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import scala.annotation.targetName
2-
def f[T](x: T)[U](y: U) = (x,y)
3-
@targetName("g") def f[T](x: T, y: T) = (x,y)
2+
3+
object nameCollision:
4+
def f[T](x: T)[U](y: U) = (x,y)
5+
@targetName("g") def f[T](x: T, y: T) = (x,y)

tests/pos/_typeInterweaving/newline.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Newline {
1+
object newline {
22
def multipleLines
33
[T]
44
(x: T)

tests/pos/_typeInterweaving/todo.scala

Lines changed: 0 additions & 157 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
object typeApply:
2+
3+
def f0[T]: [U] => T => T = ???
4+
def f1[T][U]: T => T = ???
5+
def f2[T][U](): T => T = ???
6+
def f3[T <: Int][U <: String](): T => T = ???
7+
def f4[T <: Int][U <: String]: T => T = ???
8+
def f5[T <: Int][U <: String]: [X <: Unit] => X => X = ???
9+
def f6[T <: Int][U <: String](): [X <: Unit] => X => X = ???
10+
def f7[T <: Int][U <: String]()[X <: Unit]: X => X = ???
11+
12+
@main def test = {
13+
f0[Int][String] //only one that works when lines 1088 to 1089 of Applications.scala are uncommented
14+
f1[Int][String]
15+
f2[Int][String]()
16+
f3[Int][String]()
17+
f4[Int][String]
18+
f5[Int][String]
19+
f5[Int][Unit] // Should this work ?
20+
f5[Int][String][Unit]
21+
f6[Int]()[Unit]
22+
f7[Int]()[Unit]
23+
}

0 commit comments

Comments
 (0)