Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

AndTagged: illegal cyclic reference involving type @@ #19

Open
@Ravenow

Description

@Ravenow

i have issue with following code

import cats.syntax.option._
import com.softwaremill.tagging._

object Sample extends App {
  trait ContentTypeTag
  type ContentType = String @@ ContentTypeTag

  trait ServiceContentTypeTag
  type ServiceContentType = String @@ ServiceContentTypeTag

  def method(ct: Option[ContentType]): Unit = ct match {
    case Some(v) => println(s"Content Type: $v")
    case None    => println(s"Content Type: <UNKNOWN>")
  }

  def svcMethod(ct: Option[ServiceContentType]): Unit = method(ct.map(_.andTaggedWith[ContentTypeTag]))

  svcMethod("application/json".taggedWith[ServiceContentTypeTag].some)
}

Error has gone with following AndTagger:

  implicit class AndTagger[T, U](val t: T @@ U) extends AnyVal {
    def andTaggedWith[V]: T with Tag[(U with V)] = t.asInstanceOf[T with Tag[(U with V)]]
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions