Closed
Description
minimized code
import scala.compiletime.ops.int.+
import scala.compiletime.S
class Foo[T <: Int] {
def incP = new Foo[T + 1] //Partially works
def incS = new Foo[S[T]] //Fully works
}
object Foo {
def apply[T <: Int & Singleton](value : T) : Foo[T] = new Foo[T]
}
val fincS : Foo[2] = Foo(1).incS //works
val fincP1 : Foo[2] = Foo(1).incP //error
val fincP2a = Foo(1).incP
val fincP2b : Foo[2] = fincP2a //works
val fincP3 : Foo[2] = (new Foo[1]).incP //works
Compilation output
|val fincP1 : Foo[2] = Foo(1).incP //error
| ^^^^^^^^^^^
| Found: Foo[(1 : Int) + (1 : Int)]
| Required: Foo[(2 : Int)]
expectation
No error. Notice the difference between the implementation of incP
based on int.+
and incS
based on S
. The latter works, which hints to a missing handling of the newly added compiletime ops.