scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Difference in behavior between `S[a.type]` and `a.type + 1`

Open eejbyfeldt opened this issue 3 days ago • 1 comments

Compiler version

3.8.1-RC1-bin-20251209-07883c1-NIGHTLY

Minimized code

import scala.compiletime.ops.int.+
import scala.compiletime.ops.int.S

object test {
  object O {
    opaque type O = Int
    transparent inline def v: O = 123
  }

  val a: 123 & O.O = O.v
  val b: S[a.type] = 124 // works
  val c: a.type + 1 = 124 // error
}

Output

Compiling project (Scala 3.8.1-RC1-bin-20251209-07883c1-NIGHTLY, JVM (21))
[error] ./refined.scala:12:23
[error] Found:    (124 : Int)
[error] Required: (test.a : (123 : Int) & test.O.O) + (1 : Int)
[error]   val c: a.type + 1 = 124
[error]                       ^^^
Error compiling project (Scala 3.8.1-RC1-bin-20251209-07883c1-NIGHTLY, JVM (21))
Compilation failed

Expectation

Code should compile without errors.

eejbyfeldt avatar Dec 09 '25 17:12 eejbyfeldt