Skip to content

Commit a5c01eb

Browse files
authored
Merge pull request #8135 from dotty-staging/fix-#8115
Fix #8115: Add regression test
2 parents 704d329 + 9d2853b commit a5c01eb

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed

tests/run-macros/i8115/Macro_2.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package example
2+
3+
import scala.quoted._
4+
5+
object MyClassMaker {
6+
inline def make: MyClass = ${ makeImpl }
7+
def makeImpl(given qctx: QuoteContext): Expr[MyClass] = {
8+
'{
9+
new MyClass { } /* eventually I want to add properties inside */
10+
}
11+
}
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package example
2+
3+
class MyClass { }

tests/run-macros/i8115/Test_3.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@main def Test() = {
2+
val typeclass = example.MyClassMaker.make
3+
}

tests/run-macros/i8115b/Macro_2.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example
2+
3+
import scala.quoted._
4+
5+
object MyClassMaker {
6+
inline def make: MyClass = ${ makeImpl }
7+
def makeImpl(given qctx: QuoteContext): Expr[MyClass] = {
8+
'{
9+
new MyClass {
10+
override def toString(): String = "MyClassMaker.make.MyClass"
11+
}
12+
}
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package example
2+
3+
class MyClass { }

tests/run-macros/i8115b/Test_3.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@main def Test() = {
2+
val typeclass = example.MyClassMaker.make
3+
assert(typeclass.toString == "MyClassMaker.make.MyClass")
4+
}

0 commit comments

Comments
 (0)