Skip to content

RequireMsg compile-time error message escaping code context #234

@tribbloid

Description

@tribbloid

This is a short code snippet that demonstrates the problem:

import singleton.ops.RequireMsg

object RequireMsgSpike {

  trait HasM {

    type M = Int
  }

  trait Foo {

    trait FF[T]
  }

  object Foo3 extends Foo {

    implicit def ev3[T <: HasM](
        implicit
        r: RequireMsg[false, "Just Bad Type"]
    ): Set[FF[T]] = ???
  }

  object Foo4 extends Foo {

    implicit def ev4[T <: HasM](
        implicit
        r: Int
    ): Set[FF[T]] = ???
  }

  implicitly[Set[Foo3.FF[HasM]]]
  implicitly[Set[Foo4.FF[HasM]]]
}

error message:

[Error] /***/RequireMsgSpike.scala:34:13: Just Bad Type
[Error] /***/RequireMsgSpike.scala:35:13: Just Bad Type

The second implicit error message got corrupted by the first.

if you delete the first implicit line implicitly[Set[Foo3.FF[HasM]]], the error message goes back to normal:

[Error] /home/peng/git/shapesafe/core/src/test/scala/shapesafe/core/debugging/RequireMsgSpike.scala:35:13: could not find implicit value for parameter e: Set[shapesafe.core.debugging.RequireMsgSpike.Foo4.FF[shapesafe.core.debugging.RequireMsgSpike.HasM]] (No implicit view available from shapesafe.core.debugging.RequireMsgSpike.Foo4.FF[shapesafe.core.debugging.RequireMsgSpike.HasM] => Boolean.)

I vaguely remember that RequireMsg macro overwrites @ImplicitNotFound annotation to achieve its purpose, and this implementation is derived from shapeless. So I guess the easiest way for me is to try the following solution:

  • try to reproduce it in shapeless
    • if succeed, forward-port it to singleton-ops
    • otherwise, file the same issue for shapeless, and try to write an original fix or circumvention

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions