Skip to content

Commit ed16067

Browse files
committed
Make currentClass available from Symbols
It's needed beyond MacroTransform, and its definition is independent. Also, make `defn` in Symbols not implicit. (I think its implicitness was an oversight).
1 parent 65596ee commit ed16067

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,17 @@ object Symbols {
552552
ctx.newSymbol(owner, name, flags, info, privateWithin, coord)
553553
}
554554

555-
implicit def defn(implicit ctx: Context): Definitions = ctx.definitions
556-
557555
/** Makes all denotation operations available on symbols */
558556
implicit def toDenot(sym: Symbol)(implicit ctx: Context): SymDenotation = sym.denot
559557

560558
/** Makes all class denotations available on class symbols */
561559
implicit def toClassDenot(cls: ClassSymbol)(implicit ctx: Context): ClassDenotation = cls.classDenot
562560

561+
/** The Definitions object */
562+
def defn(implicit ctx: Context): Definitions = ctx.definitions
563+
564+
/** The current class */
565+
def currentClass(implicit ctx: Context): ClassSymbol = ctx.owner.enclosingClass.asClass
566+
563567
var stubs: List[Symbol] = Nil // diagnostic
564568
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ abstract class MacroTransform extends Phase {
3838
ctx.fresh.setTree(tree).setOwner(owner)
3939
}
4040

41-
/** The current enclosing class
42-
* @pre We must be inside a class
43-
*/
44-
def currentClass(implicit ctx: Context): ClassSymbol = ctx.owner.enclosingClass.asClass
45-
4641
def transformStats(trees: List[Tree], exprOwner: Symbol)(implicit ctx: Context): List[Tree] = {
4742
def transformStat(stat: Tree): Tree = stat match {
4843
case _: Import | _: DefTree => transform(stat)

0 commit comments

Comments
 (0)