File tree 5 files changed +30
-5
lines changed
compiler/src/scala/quoted/runtime/impl/printers
5 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,8 @@ object Extractors {
177
177
this += " Alternatives(" ++= patterns += " )"
178
178
case TypedOrTest (tree, tpt) =>
179
179
this += " TypedOrTest(" += tree += " , " += tpt += " )"
180
+ case tree =>
181
+ this += s " <Internal compiler AST $tree does not have a corresponding reflect extractor> "
180
182
}
181
183
182
184
def visitConstant (x : Constant ): this .type = x match {
@@ -239,6 +241,8 @@ object Extractors {
239
241
this += " NoPrefix()"
240
242
case MatchCase (pat, rhs) =>
241
243
this += " MatchCase(" += pat += " , " += rhs += " )"
244
+ case tp =>
245
+ this += s " <Internal compiler type $tp does not have a corresponding reflect extractor> "
242
246
}
243
247
244
248
def visitSignature (sig : Signature ): this .type = {
Original file line number Diff line number Diff line change @@ -1287,7 +1287,9 @@ object SourceCode {
1287
1287
val sym = annot.tpe.typeSymbol
1288
1288
sym != Symbol .requiredClass(" scala.forceInline" ) &&
1289
1289
sym.maybeOwner != Symbol .requiredPackage(" scala.annotation.internal" )
1290
- case x => cannotBeShownAsSource(x.show(using Printer .TreeStructure ))
1290
+ case x =>
1291
+ cannotBeShownAsSource(x.show(using Printer .TreeStructure ))
1292
+ false
1291
1293
}
1292
1294
printAnnotations(annots)
1293
1295
if (annots.nonEmpty) this += " "
@@ -1462,8 +1464,8 @@ object SourceCode {
1462
1464
}
1463
1465
}
1464
1466
1465
- private def cannotBeShownAsSource (x : String ): Nothing =
1466
- throw new Exception ( s " $x does not have a source representation " )
1467
+ private def cannotBeShownAsSource (x : String ): this . type =
1468
+ this += s " < $x does not have a source representation> "
1467
1469
1468
1470
private object SpecialOp {
1469
1471
def unapply (arg : Tree ): Option [(String , List [Term ])] = arg match {
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ object Macro {
4
+
5
+ def impl (expr : Expr [Any ])(using Quotes ): Expr [Unit ] =
6
+ println(expr.show)
7
+ ' { () }
8
+
9
+ inline def macr (inline x : Any ): Unit = $ {impl(' x )}
10
+ }
Original file line number Diff line number Diff line change
1
+ trait Foo :
2
+ val x : Int
3
+ def ho (p : x.type => x.type ): Unit = ()
4
+
5
+ object Test {
6
+ var f : Foo = ???
7
+ Macro .macr:
8
+ f.ho(arg => arg)
9
+ }
Original file line number Diff line number Diff line change 1
- java.lang.Exception: NoPrefix() does not have a source representation
2
- java.lang.Exception: NoPrefix() does not have a source representation
1
+ < NoPrefix() does not have a source representation>
2
+ < NoPrefix() does not have a source representation>
3
3
NoPrefix()
You can’t perform that action at this time.
0 commit comments