Skip to content

Commit 8a2158c

Browse files
committed
Add dependent function test
1 parent f674c18 commit 8a2158c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/pos/depfun.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// The following test is derived from scala/reflect/TypeTest.scala, but using
2+
// a dependent function instead of a dependent SAM. It shows that the special treatment
3+
// using a DependentTypeTree is not needed for plain function types.
4+
// But for SAM types, the treatment is needed, otherwise TypeTest.scala does
5+
// not typecheck. Todo: Figure out the reason for this difference.
6+
object Test:
7+
8+
type F[S, T] = (x: S) => Option[x.type & T]
9+
10+
/** Trivial type test that always succeeds */
11+
def identity[T]: F[T, T] = Some(_)
12+
13+
val x: 1 = 1
14+
val y = identity(x)
15+
val z: Option[1] = y
16+
17+

0 commit comments

Comments
 (0)