Skip to content

Commit d9a1b24

Browse files
committed
wip
1 parent 4c276ce commit d9a1b24

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,10 @@ object TreeChecker {
733733
if nowDefinedSyms.contains(tree.symbol.maybeOwner) then
734734
super.assertDefined(tree)
735735

736-
override def checkNoOrphans(tp0: Type, tree: untpd.Tree = untpd.EmptyTree)(using Context): Type =
737-
// TODO: Is this fails on tests/run-macros/quoted-ToExpr-derivation-macro.
738-
// Is this a bug?
739-
tp0 // Do not check for orphans
736+
// override def checkNoOrphans(tp0: Type, tree: untpd.Tree = untpd.EmptyTree)(using Context): Type =
737+
// // TODO: Is this fails on tests/run-macros/quoted-ToExpr-derivation-macro.
738+
// // Is this a bug?
739+
// tp0 // Do not check for orphans
740740
}
741741

742742
def checkMacroGeneratedTree(original: tpd.Tree, expansion: tpd.Tree)(using Context): Unit =
@@ -753,19 +753,19 @@ object TreeChecker {
753753
catch
754754
case err: java.lang.AssertionError =>
755755
report.error(
756-
em"""Malformed tree was found while expanding macro with -Xcheck-macros.
757-
|The tree does not conform to the compiler's tree invariants.
758-
|
759-
|Macro was:
760-
|${original}
761-
|
762-
|The macro returned:
763-
|${expansion}
764-
|
765-
|Error:
766-
|${err.getMessage}
767-
|
768-
|""",
756+
s"""Malformed tree was found while expanding macro with -Xcheck-macros.
757+
|The tree does not conform to the compiler's tree invariants.
758+
|
759+
|Macro was:
760+
|${scala.quoted.runtime.impl.QuotesImpl.showDecompiledTree(original)}
761+
|
762+
|The macro returned:
763+
|${scala.quoted.runtime.impl.QuotesImpl.showDecompiledTree(expansion)}
764+
|
765+
|Error:
766+
|${err.getMessage}
767+
|
768+
|""",
769769
original
770770
)
771771

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import scala.compiletime.{erasedValue, summonFrom}
2+
3+
import scala.quoted._
4+
5+
inline given summonAfterTypeMatch: Any = ${ summonAfterTypeMatchExpr }
6+
7+
private def summonAfterTypeMatchExpr(using Quotes): Expr[Any] =
8+
Type.of[scala.Int *: EmptyTuple] match
9+
case '[ head *: EmptyTuple ] =>
10+
println(quotes.reflect.TypeRepr.of[Foo[Int]])
11+
// AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),Foo),List(
12+
// TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Int)))
13+
14+
println(quotes.reflect.TypeRepr.of[Foo[head]])
15+
// AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),Foo),List(
16+
// TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)))
17+
18+
Expr.summon[Foo[Int]].get // ok
19+
Expr.summon[Foo[head]].get
20+
21+
trait Foo[T]
22+
23+
given IntFoo[T <: Int]: Foo[T] = ???
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test: Unit = summonAfterTypeMatch

0 commit comments

Comments
 (0)