File tree 3 files changed +22
-2
lines changed
compiler/src/dotty/tools/dotc
3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1218,6 +1218,15 @@ object SymDenotations {
1218
1218
else if (this .exists) owner.enclosingMethod
1219
1219
else NoSymbol
1220
1220
1221
+ /** The closest enclosing method or static symbol containing this definition.
1222
+ * A local dummy owner is mapped to the primary constructor of the class.
1223
+ */
1224
+ final def enclosingMethodOrStatic (using Context ): Symbol =
1225
+ if this .is(Method ) || this .hasAnnotation(defn.ScalaStaticAnnot ) then symbol
1226
+ else if this .isClass then primaryConstructor
1227
+ else if this .exists then owner.enclosingMethodOrStatic
1228
+ else NoSymbol
1229
+
1221
1230
/** The closest enclosing extension method containing this definition,
1222
1231
* including methods outside the current class.
1223
1232
*/
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ object LambdaLift:
34
34
val liftedDefs : HashMap [Symbol , ListBuffer [Tree ]] = new HashMap
35
35
36
36
val deps = new Dependencies (ctx.compilationUnit.tpdTree, ctx.withPhase(thisPhase)):
37
- def isExpr (sym : Symbol )(using Context ): Boolean = sym.is(Method )
38
- def enclosure (using Context ) = ctx.owner.enclosingMethod
37
+ def isExpr (sym : Symbol )(using Context ): Boolean = sym.is(Method ) || sym.hasAnnotation(defn. ScalaStaticAnnot )
38
+ def enclosure (using Context ) = ctx.owner.enclosingMethodOrStatic
39
39
40
40
override def process (tree : Tree )(using Context ): Unit =
41
41
super .process(tree)
Original file line number Diff line number Diff line change
1
+ object Obj :
2
+ @ scala.annotation.static
3
+ val some_static_value : Int = {
4
+ val some_local_value : Int = {
5
+ val some_local_value_1 = ???
6
+ some_local_value_1
7
+ }
8
+ some_local_value
9
+ }
10
+
11
+ class Obj
You can’t perform that action at this time.
0 commit comments