From b9f14a4655039059745294802a05ad28cbaf2211 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 25 Jun 2020 10:23:21 +0200 Subject: [PATCH] Fix #9240: Add regression test This was fixed in #9221 --- tests/pos-macros/i9240/Macro_1.scala | 24 ++++++++++++++++++++++++ tests/pos-macros/i9240/Test_2.scala | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 tests/pos-macros/i9240/Macro_1.scala create mode 100644 tests/pos-macros/i9240/Test_2.scala diff --git a/tests/pos-macros/i9240/Macro_1.scala b/tests/pos-macros/i9240/Macro_1.scala new file mode 100644 index 000000000000..7f85002816ff --- /dev/null +++ b/tests/pos-macros/i9240/Macro_1.scala @@ -0,0 +1,24 @@ +import scala.quoted._ +import scala.tasty._ + +inline def diveInto[T]: String = ${ diveIntoImpl[T]() } + +def diveIntoImpl[T]()(implicit qctx: QuoteContext, ttype: scala.quoted.Type[T]): Expr[String] = + import qctx.tasty._ + Expr( unwindType(qctx.tasty)(typeOf[T]) ) + +def unwindType(reflect: Reflection)(aType: reflect.Type): String = + import reflect._ + + aType match { + case AppliedType(t,tob) => + val cs = t.classSymbol.get.primaryConstructor // this is shared + val a = cs.paramSymss // this call succeeds + // println("a: "+a) + val b = cs.paramSymss // this call explodes + // println("b: "+b) + + case _ => + } + "OK!" + diff --git a/tests/pos-macros/i9240/Test_2.scala b/tests/pos-macros/i9240/Test_2.scala new file mode 100644 index 000000000000..8d4cbf94c302 --- /dev/null +++ b/tests/pos-macros/i9240/Test_2.scala @@ -0,0 +1,4 @@ +def test = + diveInto[String] + diveInto[List[Int]] + diveInto[scala.collection.immutable.HashSet[String]]