aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/customArgs/i1050.scala
blob: 1ade1366a9b86804576c2f7279f0b09f929f28a4 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// i1050 checks failing at posttyper
trait A { type L <: Nothing }
trait B { type L >: Any}
object Test {
  lazy val x: A & B = ???
  val y: x.L = 1    // error: underlying conflicting bounds
  val z: String = y
}
object Test50 {
  trait A {
    type X = String
  }
  trait B {
    type X = Int
  }
  lazy val o: A & B = ???

  def xToString(x: o.X): String = x // error: underlying conflicting bounds

  def intToString(i: Int): String = xToString(i)

  def main(args: Array[String]) = {
    val s: String = intToString(1)
  }
}
object Test2 {

  trait C { type A }

  type T = C { type A = Any }
  type U = C { type A = Nothing }
  type X = T & U

  def main(args: Array[String]) = {
    val y: X#A = 1 // error: conflicting bounds
    val z: String = y
  }
}
object Tiark1 {
    trait A { type L <: Nothing }
    trait B { type L >: Any}
    trait U {
      lazy val p: B
      def brand(x: Any): p.L = x // error: nonfinal lazy
    }
    trait V extends U {
      lazy val p: A & B = ???
    }
    val v = new V {}
    v.brand("boom!")
}
object Tiark2 {
    trait A { type L <: Nothing }
    trait B { type L >: Any}
    trait U {
      type X <: B
      lazy val p: X
      def brand(x: Any): p.L = x // error: nonfinal lazy
    }
    trait V extends U {
      type X = B & A
      lazy val p: X = ???
    }
    val v = new V {}
    v.brand("boom!"): Nothing
}
object Tiark3 {
    trait A { type L <: Nothing }
    trait B { type L >: Any}
    trait U {
      type X <: B
      def p2: X
      final lazy val p: X = p2
      def brand(x: Any): p.L = x // error: underlying not concrete
    }
    trait V extends U {
      type X = B with A
      def p2: X = ???
    }
    val v = new V {}
    v.brand("boom!"): Nothing
}
object Tiark6 {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait X {
        val q: A & B = ???
      }
      final lazy val p: X = ???
      def brand(x: Any): p.q.L = x // error: conflicting bounds
    }
    val v = new U {}
    v.brand("boom!"): Nothing
}

object Indirect {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait X {
        val q: A & B = ???
        type M = q.L
      }
      final lazy val p: X = ???
      def brand(x: Any): p.M = x // error: conflicting bounds
    }
  def main(args: Array[String]): Unit = {
    val v = new U {}
    v.brand("boom!"): Nothing
  }
}
object Indirect2 {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait Y {
        val r: A & B = ???
      }
      trait X {
        val q: Y = ???
        type M = q.r.L
      }
      final lazy val p: X = ???
      def brand(x: Any): p.M = x // error: conflicting bounds
    }
  def main(args: Array[String]): Unit = {
    val v = new U {}
    v.brand("boom!"): Nothing
  }
}
object Rec1 {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait Y {
        type L = Int
        val r: Y
      }
      trait X {
        val q: Y = ???
        type M = q.r.L  // if we are not careful we get a stackoverflow here
      }
    }
}
object Rec2 {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait Y {
        val r: A & B & Y
      }
      trait X {
        val q: Y = ???
        type M = q.r.L
      }
      final lazy val p: X = ???
      def brand(x: Any): p.M = x // error: conflicting bounds
    }
  def main(args: Array[String]): Unit = {
    val v = new U {}
    v.brand("boom!"): Nothing
  }
}
object Indirect3 {
    trait B { type L >: Any }
    trait A { type L <: Nothing }
    trait U {
      trait Y {
        val r: Y & A & B = ???
      }
      trait X {
        val q: Y = ???
        type M = q.r.L
      }
      final lazy val p: X = ???
      def brand(x: Any): p.M = x // error: conflicting bounds
    }
  def main(args: Array[String]): Unit = {
    val v = new U {}
    v.brand("boom!"): Nothing
  }
}