tek / splain

better implicit errors for scala
MIT License
370 stars 29 forks source link

Weird interaction with refined #16

Open vil1 opened 6 years ago

vil1 commented 6 years ago

I recently stumbled upon a weird interaction between this plugin and refined.

The problem is referenced in a comment of this issue.

To put it simply, when splain is active, the macro expansion from refined start failing (with a weird ClassCastException) when used in the REPL (but everything works fine in regular compiation).

To reproduce the problem, one can define the following build.sbt

scalaVersion in ThisBuild := "2.12.4"

libraryDependencies += "eu.timepit" %% "refined" % "0.8.7"

addCompilerPlugin("io.tryp" %% "splain" % "0.2.7" cross CrossVersion.patch)

and past the following lines in the console:

import eu.timepit.refined._, api._, auto._, char._, generic._, collection._
val str: String Refined Forall[UpperCase] = "FOO"
tek commented 6 years ago

hm, looks like a problem that will need pretty extensive digging to solve…I'll see if i can find the time :worried:

steinybot commented 5 years ago

I just found a slightly different variation on this in case it helps the investigation https://github.com/fthomas/refined/issues/556

The interesting thing that I found there was that it works for compile but not for generating docs.

Comparing the output with -Ymacro-debug-verbose showed that for some reason when generating docs it prints "looking for macro implementation: macro method autoRefineV" twice but only once for compile.

steinybot commented 5 years ago

I found that it also occurs on the eu.timepit.refined.macros.RefineMacro#implApplyRef macro (macro method apply). See https://github.com/fthomas/refined/issues/556 for the specifics.

What I did notice this time is that when it fails it is actually expanding the macro twice.

tek commented 5 years ago

unfortunately, I am unable to reproduce the problem with any of the test cases specified in those issues. I assume this is just another incarnation of https://github.com/tek/splain/issues/4 :disappointed:

tribbloid commented 10 months ago

Just want to point out that we don't have a test template for REPL or ammonite or scalaCLI at the moment.

I'll figure it out eventually, but before that, please include your full error stack trace in your bug report.