I have been trying to use the refined with scalatest and am getting compiler errors at the "typer" phase: trying to do lub/glb of typevar ?F[?T, ?B]

This is my best attempt at a minimalist reproduction of the issue using a self-contained ammonite script:

import $ivy.`eu.timepit::refined:0.9.0`
import $ivy.`org.scalatestplus.play::scalatestplus-play:3.1.2`

import org.scalatest.{MustMatchers, WordSpec}

import scala.concurrent.duration._
import scala.concurrent.{Await, Future}

import eu.timepit.refined.auto.autoInfer

class RefinedSpec extends WordSpec with MustMatchers {
  val duration = 500.millis
  val fut = Future.successful("123")
  Await.result(fut, atMost = duration)
}

If you make any one of the following changes to the above it will successfully compile:

  • delete: import eu.timepit.refined.auto.autoInfer
  • remove: with MustMatchers from the class definition
  • delete: Await.result(fut, atMost = duration)

To clarify, this is a compilation error, not a runtime error. The original error is happening in a play app (scala 2.11.11) whilst running test:compile in sbt, but it's probably easier to reproduce it with the ammonite script.

The ammonite version I'm using gives version info:

Welcome to the Ammonite Repl 1.1.2                                                                                    
(Scala 2.11.12 Java 1.8.0_25)

Installed using:

sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.1.2/2.11-1.1.2) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' && amm

More error details from the ammonite example:

scala.reflect.internal.FatalError:
  trying to do lub/glb of typevar ?F[?T, ?B]
     while compiling: fail.sc
        during phase: typer
     library version: version 2.11.12
    compiler version: version 2.11.12
  reconstructed args: -nowarn -Yresolve-term-conflict:object

  last tree to typer: Ident(<argument>)
       tree position: line 15 of fail.sc
            tree tpe: String
              symbol: <none>
   symbol definition: <none> (a NoSymbol)
      symbol package: <none>
       symbol owners:
           call site: class RefinedSpec in object fail in package $file

From play sbt test:compile I also get this kind of output:

[error]   last tree to typer: Ident(<argument>)
[error]        tree position: line 13 of ...../RefinedSpec.scala
[error]             tree tpe: String
[error]               symbol: <none>
[error]    symbol definition: <none> (a NoSymbol)
[error]       symbol package: <none>
[error]        symbol owners: 
[error]            call site: class RefinedSpec in package foo in package foo
[error] 
[error] == Source file context for tree position ==
[error] 
[error]     10   val duration = 500.millis
[error]     11   val fut = Future.successful("123")
[error]     12   Await.result(fut, atMost = duration)
[error]     13 }

This isn't a serious issue as I can just remove the autoInfer import as I'm not actually using it. It will trip people up though because they'll tend to do:

import eu.timepit.refined.auto._

to get automatic conversion from compile-time constants into refined types, when they can probably just get away with:

import eu.timepit.refined.auto.autoRefineV
0

There are 0 answers