Skip to content

Commit d4dd048

Browse files
committed
Add tests for #4060 and small change in i11896
For i11896, we now no longer allow an erased val to be of a top-level type declaration X (since it is not a concrete type, per realizability rules). `class X` is used instead. Another test, `top-level-type`, was added to check this behaviour. Fix some tests using top-level types for erasedValue Add parameter-only dependency case
1 parent b429e6b commit d4dd048

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// See https://github.com/lampepfl/dotty/issues/4060#issuecomment-445808377
2-
import scala.language.experimental.erasedDefinitions
32

43
object App {
54
trait A { type L >: Any}
6-
//def upcast(a: A, x: Any): a.L = x
75
def upcast(erased a: A)(x: Any): a.L = x
8-
//lazy val p: A { type L <: Nothing } = p
9-
erased val p: A { type L <: Nothing } = p // error
6+
erased val p: A { type L <: Nothing } = p
107
def coerce(x: Any): Int = upcast(p)(x) // error
118

129
def coerceInline(x: Any): Int = upcast(compiletime.erasedValue[A {type L <: Nothing}])(x) // error
1310

11+
trait B { type L <: Nothing }
12+
def upcast_dep_parameter(erased a: B)(x: a.L) : Int = x
13+
erased val q : B { type L >: Any } = compiletime.erasedValue
14+
15+
def coerceInlineWithB(x: Any): Int = upcast_dep_parameter(q)(x) // error
16+
1417
def main(args: Array[String]): Unit = {
1518
println(coerce("Uh oh!"))
19+
println(coerceInlineWithB("Uh oh!"))
1620
}
1721
}

tests/neg-custom-args/i4060.scala

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)