Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
Fixes #15475
  • Loading branch information
nicolasstucki committed Feb 9, 2023
1 parent 1fce02e commit 4a85ec6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/pos-macros/i15475.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def test =
transform {
val a: Seq[Generic[?]] = ???
a.foreach { to =>
to.mthd()
}
}

transparent inline def transform[T](expr: T): T = ??? // if we add inline to param, it doesn't crash

trait Generic[+T] { // both covariance and contravariance cause a crash (invariance doesn't)
def mthd(): Generic[T] = ??? // has to have a parameter list to crash
}
17 changes: 17 additions & 0 deletions tests/pos-macros/i15475a/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package x

import scala.quoted.*


transparent inline def xtransform[T](inline expr:T) = ${
X.transform('expr)
}

object X {

def transform[T:Type](x: Expr[T])(using Quotes):Expr[T] = {
import quotes.reflect.*
x
}

}
15 changes: 15 additions & 0 deletions tests/pos-macros/i15475a/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package x

def hello = {
xtransform {
val a: Seq[Generic[?]] = null
a
.foreach { to =>
to.mthd()
}
}
}

trait Generic[+T] {
def mthd(): Generic[T] = this
}

0 comments on commit 4a85ec6

Please sign in to comment.