Skip to content

[BUG]: Macro error when compiling with -Wsafe-init #1414

@gcsolaroli

Description

@gcsolaroli

Version

RC-1.0

Scala Version

3.7..2

Expected Behavior

I would expect the compiler to succeed even when the -Wsafe-init flat is enabled.

It's not clear to me if this is a problem triggered by Kyo's own macro code, or is it a compiler error in the code path handling the -Wsafe-init option, for a condition triggered by Kyo's code and not correctly handled.

Actual Behavior

When compiling the following code with the -Wsafe-init compiler option, the compiler fails with a macro expansion error.

ThisBuild / scalacOptions ++= Seq("-Wsafe-init")
import java.security.MessageDigest
import kyo.Sink

val sha256: Sink[Byte, Array[Byte], Any] = {
    val digest = MessageDigest.getInstance("SHA-256")
    Sink.foreach((b: Byte) => digest.update(b)).map(_ => digest.digest())
}
[error]  6 |    Sink.foreach((b: Byte) => digest.update(b)).map(_ => digest.digest())
[error]    |                                               ^
[error]    |Exception occurred while executing macro expansion.
[error]    |scala.MatchError: HKTypeLambda(List(A), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Any))), OrType(TypeRef(ThisType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object kyo),module class Maybe$package$)),type Absent),AppliedType(TypeRef(TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object kyo),object Maybe$package),object Maybe),type Present),List(TypeParamRef(A))))) (of class dotty.tools.dotc.core.Types$HKTypeLambda)

Steps to Reproduce

Setting the -Wsafe-init option for the compiler will result in the above error.
Removing the -Wsafe-init option the compilation completes successfully.

Current Workaround

Remove the -Wsafe-init compiler option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions