Skip to content

Commit 7bf29f0

Browse files
committed
Treat references to modules and lazy vals as outer references
Previously, we considered only methods. #503 shows that this is wrong.
1 parent 4808d1d commit 7bf29f0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ object ExplicitOuter {
213213
case id: Ident =>
214214
id.tpe match {
215215
case ref @ TermRef(NoPrefix, _) =>
216-
ref.symbol.is(Method) && isOuter(id.symbol.owner.enclosingClass)
216+
ref.symbol.is(Hoistable) && isOuter(id.symbol.owner.enclosingClass)
217217
// methods will be placed in enclosing class scope by LambdaLift, so they will get
218218
// an outer path then.
219219
case _ => false
@@ -225,6 +225,8 @@ object ExplicitOuter {
225225
}
226226
}
227227

228+
private final val Hoistable = Method | Lazy | Module
229+
228230
/** The outer prefix implied by type `tpe` */
229231
private def outerPrefix(tpe: Type)(implicit ctx: Context): Type = tpe match {
230232
case tpe: TypeRef =>

tests/pos/i503.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class HelloWorld {
2+
def main(args: Array[String]): Unit = {
3+
object TypeBool;
4+
5+
class Fct {
6+
def g(x : Int) = TypeBool // breaks.
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)