Skip to content

Add regression test #11391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/neg-macros/i11386.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

-- Error: tests/neg-macros/i11386/Test_2.scala:6:10 --------------------------------------------------------------------
6 | dummy(0) // error
| ^
| test
| This location contains code that was inlined from Test_2.scala:6
| This location contains code that was inlined from Macro_1.scala:7
-- Error: tests/neg-macros/i11386/Test_2.scala:8:20 --------------------------------------------------------------------
8 | dummy(int2String(0)) // error
| ^^^^^^^^^^^^^
| test
| This location contains code that was inlined from Test_2.scala:8
| This location contains code that was inlined from Macro_1.scala:7
18 changes: 18 additions & 0 deletions tests/neg-macros/i11386/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import scala.language.implicitConversions
import scala.quoted._

object test {

inline implicit def int2String(inline i: Int): String = {
notNull(i)
String.valueOf(i)
}

inline def notNull(inline i: Int): Unit = ${notNullImpl('i)}

def notNullImpl(expr: Expr[Int])(using quotes: Quotes): Expr[Unit] = {
println(expr.show)
expr.value.foreach(i => if(i == 0) quotes.reflect.report.error("test"))
'{()}
}
}
13 changes: 13 additions & 0 deletions tests/neg-macros/i11386/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import test._

object Main {

@main def dottyTest(): Unit = {
dummy(0) // error
dummy(1)
dummy(int2String(0)) // error
dummy(int2String(1))
}

def dummy(msg: String): Unit = println(msg) //A simple dummy method to call implicitly test.int2String
}