@@ -101,8 +101,8 @@ object Macros {
101
101
findOwner(c)(owner, c => owner0 => {import c .{given _ }; owner0.flags.is(c.Flags .Macro ) && Util .getName(c)(owner0) == " macro" })
102
102
103
103
def nameImpl (using ctx : QuoteContext ): Expr [Name ] = {
104
- import ctx .tasty .{ given _ }
105
- val owner = actualOwner(ctx.tasty)(ctx.tasty.rootContext.owner )
104
+ import ctx .tasty ._
105
+ val owner = actualOwner(ctx.tasty)(Symbol .currentOwner )
106
106
val simpleName = Util .getName(ctx.tasty)(owner)
107
107
' {Name ($ {Expr (simpleName)})}
108
108
}
@@ -115,19 +115,19 @@ object Macros {
115
115
s
116
116
117
117
def nameMachineImpl (using ctx : QuoteContext ): Expr [Name .Machine ] = {
118
- import ctx .tasty .{ given _ }
119
- val owner = nonMacroOwner(ctx.tasty)(ctx.tasty.rootContext.owner )
118
+ import ctx .tasty ._
119
+ val owner = nonMacroOwner(ctx.tasty)(Symbol .currentOwner )
120
120
val simpleName = adjustName(Util .getName(ctx.tasty)(owner))
121
121
' {Name .Machine ($ {Expr (simpleName)})}
122
122
}
123
123
124
124
def fullNameImpl (using ctx : QuoteContext ): Expr [FullName ] = {
125
- import ctx .tasty .{ given _ }
125
+ import ctx .tasty ._
126
126
@ annotation.tailrec def cleanChunk (chunk : String ): String =
127
127
val refined = chunk.stripPrefix(" _$" ).stripSuffix(" $" )
128
128
if chunk != refined then cleanChunk(refined) else refined
129
129
130
- val owner = actualOwner(ctx.tasty)(ctx.tasty.rootContext.owner )
130
+ val owner = actualOwner(ctx.tasty)(Symbol .currentOwner )
131
131
val fullName =
132
132
owner.fullName.trim
133
133
.split(" \\ ." , - 1 )
@@ -138,8 +138,8 @@ object Macros {
138
138
}
139
139
140
140
def fullNameMachineImpl (using ctx : QuoteContext ): Expr [FullName .Machine ] = {
141
- import ctx .tasty .{ given _ }
142
- val owner = nonMacroOwner(ctx.tasty)(ctx.tasty.rootContext.owner )
141
+ import ctx .tasty ._
142
+ val owner = nonMacroOwner(ctx.tasty)(Symbol .currentOwner )
143
143
val fullName = owner.fullName.trim
144
144
.split(" \\ ." , - 1 )
145
145
.map(_.stripPrefix(" _$" ).stripSuffix(" $" )) // meh
@@ -149,19 +149,19 @@ object Macros {
149
149
}
150
150
151
151
def fileImpl (using ctx : QuoteContext ): Expr [sourcecode.File ] = {
152
- import ctx .tasty .{ given _ }
152
+ import ctx .tasty ._
153
153
val file = ctx.tasty.rootPosition.sourceFile.jpath.toAbsolutePath.toString
154
154
' {sourcecode.File ($ {Expr (file)})}
155
155
}
156
156
157
157
def fileNameImpl (using ctx : QuoteContext ): Expr [sourcecode.FileName ] = {
158
- import ctx .tasty .{ given _ }
158
+ import ctx .tasty ._
159
159
val name = ctx.tasty.rootPosition.sourceFile.jpath.getFileName.toString
160
160
' {sourcecode.FileName ($ {Expr (name)})}
161
161
}
162
162
163
163
def lineImpl (using ctx : QuoteContext ): Expr [sourcecode.Line ] = {
164
- import ctx .tasty .{ given _ }
164
+ import ctx .tasty ._
165
165
val line = ctx.tasty.rootPosition.startLine + 1
166
166
' {sourcecode.Line ($ {Expr (line)})}
167
167
}
@@ -180,7 +180,7 @@ object Macros {
180
180
}
181
181
182
182
def pkgImpl (using ctx : QuoteContext ): Expr [Pkg ] = {
183
- import ctx .tasty .{ given _ }
183
+ import ctx .tasty ._
184
184
val path = enclosing(ctx.tasty) {
185
185
case s if s.isPackageDef => true
186
186
case _ => false
@@ -190,7 +190,7 @@ object Macros {
190
190
}
191
191
192
192
def argsImpl (using ctx : QuoteContext ): Expr [Args ] = {
193
- import ctx .tasty .{ _ , given _ }
193
+ import ctx .tasty ._
194
194
195
195
val param : List [List [ctx.tasty.ValDef ]] = {
196
196
def nearestEnclosingMethod (owner : ctx.tasty.Symbol ): List [List [ctx.tasty.ValDef ]] =
@@ -203,7 +203,7 @@ object Macros {
203
203
nearestEnclosingMethod(owner.owner)
204
204
}
205
205
206
- nearestEnclosingMethod(ctx.tasty.rootContext.owner )
206
+ nearestEnclosingMethod(Symbol .currentOwner )
207
207
}
208
208
209
209
val texts0 = param.map(_.foldRight(' {List .empty[Text [_]]}) {
@@ -220,7 +220,7 @@ object Macros {
220
220
221
221
222
222
def text [T : Type ](v : Expr [T ])(using ctx : QuoteContext ): Expr [sourcecode.Text [T ]] = {
223
- import ctx .tasty .{ given _ }
223
+ import ctx .tasty ._
224
224
val txt = v.unseal.pos.sourceCode
225
225
' {sourcecode.Text [T ]($v, $ {Expr (txt)})}
226
226
}
@@ -234,9 +234,9 @@ object Macros {
234
234
}
235
235
236
236
def enclosing (c : Reflection , machine : Boolean = false )(filter : c.Symbol => Boolean ): String = {
237
- import c .{ _ , given _ }
237
+ import c ._
238
238
239
- var current = c.rootContext.owner
239
+ var current = Symbol .currentOwner
240
240
if (! machine)
241
241
current = actualOwner(c)(current)
242
242
else
0 commit comments