Skip to content
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

AndTagged: illegal cyclic reference involving type @@ #19

Open
Ravenow opened this issue Feb 8, 2021 · 1 comment
Open

AndTagged: illegal cyclic reference involving type @@ #19

Ravenow opened this issue Feb 8, 2021 · 1 comment

Comments

@Ravenow
Copy link

Ravenow commented Feb 8, 2021

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)]]
  }
@adamw
Copy link
Member

adamw commented Mar 19, 2021

Hm true, but then the inferred type has the ... with Tag format, not the @@ format. Not sure how to fix it while retaining the @@ notation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants