Skip to content

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

@eejbyfeldt

Description

@eejbyfeldt

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions