Skip to content

Dependent type is not working in Scala version 3.3.0-RC3 #17181

Closed
@chungonn

Description

@chungonn

Compiler version 3.3.0-RC3 and 3.3.1-nightly version

Minimized code

The code works from Scala 3.1.x up to 3.2.2
inline def foo[A](inline a: A)(fn: a.type => String): String =
fn(a)

@main def hello() =
val x= foo("hello")( (s: "hello") => s + " world!")
println(s"x = ${x}")

val y = foo(1)((s: 1) => s + " world!")
println(s"y = ${y}")

println("hello, world")

Output

[error] -- [E083] Type Error: /home/chungonn/development/experiments/scala3test/src/main/scala/Main.scala:2:35 
[error] 2 |inline def foo[A](inline a: A)(fn: a.type => String): String =
[error]   |                                   ^^^^^^
[error]   |  (a : A) is not a valid singleton type, since it is not an immutable path
[error]   |
[error]   | longer explanation available when compiling with `-explain`
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed 30 Mar 2023, 11:26:36 am

Expectation

x = hello world!
y = 1 world!

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions