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 @@ -1232,6 +1232,15 @@ object SymDenotations {
1232
1232
else if (this .exists) owner.enclosingMethod
1233
1233
else NoSymbol
1234
1234
1235
+ /** The closest enclosing method or static symbol containing this definition.
1236
+ * A local dummy owner is mapped to the primary constructor of the class.
1237
+ */
1238
+ final def enclosingMethodOrStatic (using Context ): Symbol =
1239
+ if this .is(Method ) || this .hasAnnotation(defn.ScalaStaticAnnot ) then symbol
1240
+ else if this .isClass then primaryConstructor
1241
+ else if this .exists then owner.enclosingMethodOrStatic
1242
+ else NoSymbol
1243
+
1235
1244
/** The closest enclosing extension method containing this definition,
1236
1245
* including methods outside the current class.
1237
1246
*/
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ object LambdaLift:
36
36
val liftedDefs : HashMap [Symbol , ListBuffer [Tree ]] = new HashMap
37
37
38
38
val deps = new Dependencies (ctx.compilationUnit.tpdTree, ctx.withPhase(thisPhase)):
39
- def isExpr (sym : Symbol )(using Context ): Boolean = sym.is(Method )
40
- def enclosure (using Context ) = ctx.owner.enclosingMethod
39
+ def isExpr (sym : Symbol )(using Context ): Boolean = sym.is(Method ) || sym.hasAnnotation(defn. ScalaStaticAnnot )
40
+ def enclosure (using Context ) = ctx.owner.enclosingMethodOrStatic
41
41
42
42
override def process (tree : Tree )(using Context ): Unit =
43
43
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