Closed
Description
Compiler version
Last working version: 3.3.1
Not working versions: 3.3.3
and 3.4.0
Did not test nightly versions
Minimized code
import scala.language.implicitConversions
object Main:
implicit inline def uhOh[A](value: A): A =
compiletime.error("Should not have been called")
//Same signature than `Function1` but behaves differently (summoning works as expected)
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
trait Foo[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R]
@main
def testMain =
summon[Function1[Int, Int]] //Calls `uhOh` in 3.3.3 but not in 3.3.2
Opaque type variant (also not working)
opaque type Bar[A] <: A = A
import scala.language.implicitConversions
object Main:
implicit inline def uhOh[A](value: A): Bar[A] =
compiletime.error("Should not have been called")
//Same signature than `Function1` but behaves differently (summoning works as expected)
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
trait Foo[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R]
@main
def testMain =
summon[Function1[Int, Int]] //Calls `uhOh` in 3.3.3 but not in 3.3.2
Output
[error] 14 | summon[Function1[Int, Int]] //Calls `uhOh` in 3.3.3 but not in 3.3.2
[error] | ^
[error] | Should not have been called
Notes:
uhOh
is not called in 3.3.1- It only happens when summoning a
Function1
.summon[Foo[Int, Int]]
works as expected ("no given instance ofFoo
..."). - The generic parameter
A
is important. Replacing it byAny
does not produce the error.
Expectation
I would expect this sample to compile as it did in 3.3.1
.
Real world example
uhOh
looks meaningless but this issue also breaks actually useful code. For example in a library I have an inline implicit conversion which converts a type A
to an opaque type IronType[A, C] <: A
impacted by the problem described above, for example in its Scalacheck module.