splain icon indicating copy to clipboard operation
splain copied to clipboard

Weird interaction with refined

Open vil1 opened this issue 7 years ago • 5 comments

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"

vil1 avatar Mar 15 '18 12:03 vil1

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

tek avatar Mar 15 '18 21:03 tek

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 avatar Aug 09 '18 08:08 steinybot

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.

steinybot avatar Aug 09 '18 08:08 steinybot

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:

tek avatar Aug 09 '18 16:08 tek

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.

tribbloid avatar Oct 06 '23 17:10 tribbloid