File tree Expand file tree Collapse file tree 11 files changed +131
-1
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 11 files changed +131
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ object Inferencing {
8282 force.appliesTo(tvar) && {
8383 val direction = instDirection(tvar.origin)
8484 if (direction != 0 ) {
85- if (direction > 0 ) println(s " inst $tvar dir = up " )
85+ // if (direction > 0) println(s"inst $tvar dir = up")
8686 instantiate(tvar, direction < 0 )
8787 }
8888 else {
Original file line number Diff line number Diff line change 1+ import scala .reflect ._
2+ // this needs to be fleshed out further
3+ class Contra [- T ]
4+
5+ object Test {
6+ def getParam [T ](c : Contra [T ])(implicit ct : ClassTag [T ]): Unit = {
7+ println(ct)
8+ ct
9+ }
10+ def f [T ](x : Contra [T ]): Contra [T ] = x
11+
12+ def main (args : Array [String ]): Unit = {
13+ val x = f(new Contra [Int ])
14+ val y : Contra [Int ] = x
15+ getParam(new Contra [Int ])
16+ }
17+ }
18+
Original file line number Diff line number Diff line change 1+ // demonstrates selection on non-path types. Needs to be fleshed out to
2+ // become a real test.
3+ object Test {
4+
5+ class C {
6+ type T
7+ val f : T => T = ???
8+ }
9+
10+ var x = new C
11+ val y = x.f
12+
13+
14+ }
Original file line number Diff line number Diff line change 1+ // infers wrong instance --> an implementatioin is missing
2+ trait Ord [- T ] {
3+ def less (x : T , y : T ): Boolean
4+ }
5+
6+ object Test {
7+
8+ implicit val anyIsOrd : Ord [Any ] = new Ord [Any ] {
9+ def less (x : Any , y : Any ): Boolean = ???
10+ }
11+
12+ implicit val intIsOrd : Ord [Int ] = new Ord [Int ] {
13+ def less (x : Int , y : Int ): Boolean = x < y
14+ }
15+
16+ def less [T : Ord ](x : T , y : T ): Boolean =
17+ implicitly[Ord [T ]].less(x, y)
18+
19+ def main (args : Array [String ]) =
20+ assert(less(1 , 2 ))
21+
22+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+ final val x = 2
3+ final val y = { println(" x" ); 2 }
4+ val x1 = x
5+ val y1 = y
6+ object O { val x = 42 }
7+ println(O .x)
8+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+
3+ def f [X ]: (Set [X ], Set [X ]) = ???
4+
5+ val a = if (true ) f else (Set [Int ](), Set [String ]())
6+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+
3+ def f [T ](x : T , y : T ): T = x
4+ def g [T ](x : T )(y : T ): T = x
5+
6+ val x : Int = 1
7+ val y : Long = x
8+
9+ val xs : Seq [Int ] = Seq (1 )
10+ val ys : Traversable [Int ] = xs
11+
12+ val r1 = f(x, y)
13+ val s1 : AnyVal = r1
14+ val r2 = f(y, x)
15+ val s2 : AnyVal = r2
16+ val r3 = f(xs, ys)
17+ val s3 : Traversable [Int ] = r3
18+ val r4 = f(ys, xs)
19+ val s4 : Traversable [Int ] = r4
20+ val r5 = g(x)(y)
21+ val s5 : AnyVal = r5
22+ val r6 = g(y)(x)
23+ val s6 : AnyVal = r6
24+ val r7 = g(xs)(ys)
25+ val s7 : Traversable [Int ]= r7
26+ val r8 = g(ys)(xs)
27+ val s8 : Traversable [Int ] = r8
28+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+
3+ val subPatBinders = List [Symbol ]()
4+
5+ def extraStoredBinders : Set [Symbol ] = ???
6+
7+ val storedBinders : Set [Symbol ] =
8+ (if (true ) subPatBinders.toSet else Set .empty) ++ extraStoredBinders// -- ignoredSubPatBinders
9+
10+
11+ }
Original file line number Diff line number Diff line change 1+ trait T {
2+ def foo (a : List [String ]): String = " 1"
3+ def foo (a : List [Int ]): Int = 1
4+ foo(List (" 1" ))
5+ foo(List (1 ))
6+ }
7+ // to be compiled by dotty
8+ object Test extends T {
9+ def main (args : Array [String ]): Unit = ()
10+ }
Original file line number Diff line number Diff line change 1+ 53.0
2+ 53.0
You can’t perform that action at this time.
0 commit comments