Skip to content

Commit 41bcd12

Browse files
committed
Fix #4060 by marking ghost symbols as unstable
1 parent 4cfffbe commit 41bcd12

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/SymDenotations.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ object SymDenotations {
600600

601601
/** Is this a denotation of a stable term (or an arbitrary type)? */
602602
final def isStable(implicit ctx: Context) =
603-
isType || is(Stable) || !(is(UnstableValue) || info.isInstanceOf[ExprType])
603+
!is(Ghost) && (isType || is(Stable) || !(is(UnstableValue) || info.isInstanceOf[ExprType]))
604604

605605
/** Is this a "real" method? A real method is a method which is:
606606
* - not an accessor

Diff for: tests/neg/i4060.scala

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class X { type R }
2+
class T(ghost val a: X)(val value: a.R) // error
3+
4+
object App {
5+
def coerce[U, V](u: U): V = {
6+
trait X { type R >: U }
7+
trait Y { type R = V }
8+
9+
class T[A <: X](ghost val a: A)(val value: a.R) // error
10+
11+
object O { lazy val x : Y & X = ??? } // warning
12+
13+
val a = new T[Y & X](O.x)(u)
14+
a.value
15+
}
16+
17+
def main(args: Array[String]): Unit = {
18+
val x: Int = coerce[String, Int]("a")
19+
println(x + 1)
20+
21+
}
22+
}

0 commit comments

Comments
 (0)