Closed
Description
Compiler version
3.0.0-M3
Minimized code
Main.scala
import test._
object Main {
@main def dottyTest(): Unit = {
dummy(1)
}
def dummy(msg: String): Unit = println(msg) //A simple dummy method to call implicitly test.int2String
}
test.scala
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] = {
expr.value.foreach(i => if(i == 0) quotes.reflect.report.error("test"))
'{()}
}
}
Output
Using a non-null Int: OK
The code compiles and works as expected
Using zero: dummy(0)
[info] Compiling 1 Scala source to C:\Users\rapha\IdeaProjects\ScalaLint\out\main\compile\dest\classes ...
[error] -- [E007] Type Mismatch Error: C:\Users\rapha\IdeaProjects\ScalaLint\main\src\io\github\iltotore\scalalint\Main.scala:19:10
[error] 19 | dummy(0)
[error] | ^
[error] | Found: (0 : Int)
[error] | Required: String
[error] one error found
Using zero but calling the conversion method explicitly: OK
[info] Compiling 1 Scala source to C:\Users\rapha\IdeaProjects\ScalaLint\out\main\compile\dest\classes ...
[error] -- Error: C:\Users\rapha\IdeaProjects\ScalaLint\main\src\io\github\iltotore\scalalint\Main.scala:19:20
[error] 19 | dummy(int2String(0))
[error] | ^^^^^^^^^^^^^
[error] | test
[error] | This location contains code that was inlined from Main.scala:19
[error] | This location contains code that was inlined from test.scala:9
This is the expected message
Expectation
The compiler should show the test
error message like in the third case (Using zero but calling the method explicitly)