Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScalaTest v3: why require to implement convertToLegacyEqualizer

Using ScalaTest 3.0.0 Environment: Scala 2.11.8, sbt 0.13.5, IntelliJ 14.1.4

build.sbt has only

// NOTE: not using org.scalactic
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"

The test below passed. However, IntelliJ marks a squiggly red line below MyMiniTest with the warning message:

Class 'MyMiniTest ' must either be declared abstract or implement abstract member 'convertToLegacyEqualizer[T](left: T): TripleEqualsSupport.this.LegacyEqualizer[T]' in 'org.scalactic.TripleEqualsSupport'

import org.scalatest.FeatureSpec

class MyMiniTest extends FeatureSpec {
  scenario("A simple test") {
    val a = 12
    assert(a * 3 == 36)
  }
}

What is the reason of this warning and what is the recommended solution to fix it?

like image 634
Polymerase Avatar asked Oct 07 '16 20:10

Polymerase


2 Answers

I had the same problem on IntelliJ just follow this steps to invalidate cache/restart. This will solve the problem.

like image 183
igx Avatar answered Nov 01 '22 11:11

igx


In my case it was a transitive dependency (don't know how a test library could appear as such) of a different version clashing with the dependency defined in my project. SBT knows how to deal with most of these cases, IntelliJ doesn't seem to know. Note that invalidating the cache and restarting IntelliJ wouldn't help in this case.

To be sure it's your case, check the following: File -> Project Structure -> [Project Settings - Libraries]. Look for org.scalatest:* and you will probably find two libraries, like this: enter image description here

Then remove the unnecessary one by selecting it and pressing - at the top of the panel. That's it, IntelliJ will be happy now.

A cleaner solution would be to exclude the unnecessary library from your dependencies, e.g.: ExclusionRule("org.scalatest", "scalatest_2.11-2.2.4")

IntelliJ will show the library among the project's dependencies, but will know that it should be ingored.

like image 32
Sergio Pelin Avatar answered Nov 01 '22 11:11

Sergio Pelin