Skip to content

Commit 605ec8a

Browse files
committed
Another regression test for bad bounds
This one comes from #5854.
1 parent 593cb2f commit 605ec8a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class CompilationTests extends ParallelTesting {
155155
compileFile("tests/neg-custom-args/overrideClass.scala", scala2Mode) +
156156
compileFile("tests/neg-custom-args/autoTuplingTest.scala", defaultOptions.and("-language:noAutoTupling")) +
157157
compileFile("tests/neg-custom-args/i1050.scala", defaultOptions.and("-strict")) +
158+
compileFile("tests/neg-custom-args/nullless.scala", defaultOptions.and("-strict")) +
158159
compileFile("tests/neg-custom-args/nopredef.scala", defaultOptions.and("-Yno-predef")) +
159160
compileFile("tests/neg-custom-args/noimports.scala", defaultOptions.and("-Yno-imports")) +
160161
compileFile("tests/neg-custom-args/noimports2.scala", defaultOptions.and("-Yno-imports")) +

tests/neg/nullless.scala

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
object nullless {
2+
trait LowerBound[T] {
3+
type M >: T;
4+
}
5+
trait UpperBound[U] {
6+
type M <: U;
7+
}
8+
lazy val nothing : Nothing = nothing
9+
class Box[V](val v: V)
10+
lazy val box : Box[UpperBound[String] & LowerBound[Int]] = new Box(nothing)
11+
def upcast(t : box.v.M) : box.v.M = t // error // error under -strict
12+
def main(args : Array[String]) : Unit = {
13+
val zero : String = upcast(0)
14+
println("...")
15+
}
16+
}
17+
object bar {
18+
trait Sub {
19+
type M
20+
type L <: M
21+
type U >: M
22+
type M2 >: L <: U
23+
}
24+
class Box[V](val v: V)
25+
26+
class Caster[LL, UU] {
27+
trait S2 {
28+
type L = LL
29+
type U = UU
30+
}
31+
final lazy val nothing: Nothing = nothing
32+
final lazy val sub: S2 with Sub = nothing
33+
final lazy val box : Box[S2 with Sub] = new Box(nothing)
34+
def upcast(t: box.v.M2): box.v.M2 = t // error // error under -strict
35+
}
36+
def main(args : Array[String]) : Unit = {
37+
val zero : String = (new Caster[Int,String]()).upcast(0)
38+
println("...")
39+
}
40+
}

0 commit comments

Comments
 (0)