Skip to content

Compiletime primitive ops fail to stabilize #8280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
soronpo opened this issue Feb 11, 2020 · 0 comments
Closed

Compiletime primitive ops fail to stabilize #8280

soronpo opened this issue Feb 11, 2020 · 0 comments
Assignees

Comments

@soronpo
Copy link
Contributor

soronpo commented Feb 11, 2020

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.

cc @OlivierBlanvillain @MaximeKjaer

soronpo added a commit to soronpo/scala3 that referenced this issue Feb 11, 2020
odersky added a commit that referenced this issue Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants