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 {
@@ -241,6 +243,8 @@ object Extractors {
241
243
this += " MatchCase(" += pat += " , " += rhs += " )"
242
244
case FlexibleType (tp) =>
243
245
this += " FlexibleType(" += tp += " )"
246
+ case tp =>
247
+ this += s " <Internal compiler type $tp does not have a corresponding reflect extractor> "
244
248
}
245
249
246
250
def visitSignature (sig : Signature ): this .type = {
Original file line number Diff line number Diff line change @@ -1292,7 +1292,9 @@ object SourceCode {
1292
1292
val sym = annot.tpe.typeSymbol
1293
1293
sym != Symbol .requiredClass(" scala.forceInline" ) &&
1294
1294
sym.maybeOwner != Symbol .requiredPackage(" scala.annotation.internal" )
1295
- case x => cannotBeShownAsSource(x.show(using Printer .TreeStructure ))
1295
+ case x =>
1296
+ cannotBeShownAsSource(x.show(using Printer .TreeStructure ))
1297
+ false
1296
1298
}
1297
1299
printAnnotations(annots)
1298
1300
if (annots.nonEmpty) this += " "
@@ -1463,8 +1465,8 @@ object SourceCode {
1463
1465
}
1464
1466
}
1465
1467
1466
- private def cannotBeShownAsSource (x : String ): Nothing =
1467
- throw new Exception ( s " $x does not have a source representation " )
1468
+ private def cannotBeShownAsSource (x : String ): this . type =
1469
+ this += s " < $x does not have a source representation> "
1468
1470
1469
1471
private object SpecialOp {
1470
1472
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