summaryrefslogtreecommitdiff
path: root/test/files/run/existentials-in-compiler.scala
blob: e35b7231c2d3fc2342afd8f583d41b3c50301214 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * filter: inliner warnings; re-run with
 */
import scala.tools.nsc._
import scala.tools.partest.CompilerTest
import scala.collection.{ mutable, immutable, generic }

object Test extends CompilerTest {
  import global._
  import rootMirror._
  import definitions._

  override def code = """
package extest {
  trait Bippy[A <: AnyRef, B] { }     // wildcards
  trait BippyLike[A <: AnyRef, B <: List[A], This <: BippyLike[A, B, This] with Bippy[A, B]]  // no wildcards
  trait BippyBud[A <: AnyRef, B, C <: List[A]]

  trait Cov01[+A <: AnyRef, +B] { }
  trait Cov02[+A <: AnyRef,  B] { }
  trait Cov03[+A <: AnyRef, -B] { }
  trait Cov04[ A <: AnyRef, +B] { }
  trait Cov05[ A <: AnyRef,  B] { }
  trait Cov06[ A <: AnyRef, -B] { }
  trait Cov07[-A <: AnyRef, +B] { }
  trait Cov08[-A <: AnyRef,  B] { }
  trait Cov09[-A <: AnyRef, -B] { }

  trait Cov11[+A <: AnyRef, +B <: List[_]] { }
  trait Cov12[+A <: AnyRef,  B <: List[_]] { }
  trait Cov13[+A <: AnyRef, -B <: List[_]] { }
  trait Cov14[ A <: AnyRef, +B <: List[_]] { }
  trait Cov15[ A <: AnyRef,  B <: List[_]] { }
  trait Cov16[ A <: AnyRef, -B <: List[_]] { }
  trait Cov17[-A <: AnyRef, +B <: List[_]] { }
  trait Cov18[-A <: AnyRef,  B <: List[_]] { }
  trait Cov19[-A <: AnyRef, -B <: List[_]] { }

  trait Cov21[+A, +B] { }
  trait Cov22[+A,  B] { }
  trait Cov23[+A, -B] { }
  trait Cov24[ A, +B] { }
  trait Cov25[ A,  B] { }
  trait Cov26[ A, -B] { }
  trait Cov27[-A, +B] { }
  trait Cov28[-A,  B] { }
  trait Cov29[-A, -B] { }

  trait Cov31[+A, +B, C <: ((A, B))] { }
  trait Cov32[+A,  B, C <: ((A, B))] { }
  trait Cov33[+A, -B, C <: ((A, _))] { }
  trait Cov34[ A, +B, C <: ((A, B))] { }
  trait Cov35[ A,  B, C <: ((A, B))] { }
  trait Cov36[ A, -B, C <: ((A, _))] { }
  trait Cov37[-A, +B, C <: ((_, B))] { }
  trait Cov38[-A,  B, C <: ((_, B))] { }
  trait Cov39[-A, -B, C <: ((_, _))] { }

  trait Cov41[+A >: Null, +B] { }
  trait Cov42[+A >: Null,  B] { }
  trait Cov43[+A >: Null, -B] { }
  trait Cov44[ A >: Null, +B] { }
  trait Cov45[ A >: Null,  B] { }
  trait Cov46[ A >: Null, -B] { }
  trait Cov47[-A >: Null, +B] { }
  trait Cov48[-A >: Null,  B] { }
  trait Cov49[-A >: Null, -B] { }

  trait Covariant[+A <: AnyRef, +B] { }
  trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: CovariantLike[A, B, This] with Covariant[A, B]]

  trait Contra[-A >: AnyRef, -B] { }
  trait ContraLike[-A >: AnyRef, -B >: List[A]]
}
  """

  override def check(source: String, unit: global.CompilationUnit) {
    getPackage(TermName("extest")).moduleClass.info.decls.toList.filter(_.isType).map(_.initialize).sortBy(_.name.toString) foreach { clazz =>
      exitingTyper {
        clazz.info
        println(clazz.defString)
        println("    " + classExistentialType(clazz.owner.typeOfThis, clazz) + "\n")
      }
    }
  }
}