diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 44629c036c2f..bc253021f973 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -744,7 +744,8 @@ object SymDenotations { final def enclosingMethod(implicit ctx: Context): Symbol = if (this is (Method, butNot = Label)) symbol else if (this.isClass) primaryConstructor - else owner.enclosingMethod + else if (this.exists) owner.enclosingMethod + else NoSymbol /** The top-level class containing this denotation, * except for a toplevel module, where its module class is returned. diff --git a/tests/pos/KillLambdaLift.scala b/tests/pos/KillLambdaLift.scala new file mode 100644 index 000000000000..23a40da5ed9e --- /dev/null +++ b/tests/pos/KillLambdaLift.scala @@ -0,0 +1,3 @@ +class KillLambdaLift { + private def com: this.type = _root_.scala.Predef.??? +}