16

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?

Polymerase
  • 6,311
  • 11
  • 47
  • 65

3 Answers3

6

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

igx
  • 4,101
  • 11
  • 43
  • 88
  • I think (but not sure) I have already tried invalidate cache/restart of IntelliJ. It's going to take sometimes to try this again as we have decided to revert back to Scalatest 2.2.5 for now. Thank you for your help. I'll do this next time we have the opportunity to upgrade Scalatest for good. – Polymerase Nov 08 '16 at 18:58
  • Thanks, this helped me a lot! – Oviron Jan 30 '17 at 11:12
  • Invalidating cache and restart, and even removing `.idea` file and all `target` folders and opening the project afresh, doesn't solve the issue. – Sergio Pelin Aug 30 '19 at 11:47
2

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.

Sergio Pelin
  • 874
  • 7
  • 22
0

Please check all you dependencies and check if any of those dependencies is downloading org.scalatest.* . If the version of org.scalatest.* you have defined is different from the one getting downloaded due to other defined dependencies, this issue occurs. I was using org.mockito%mockito-scala whose pom defined that scalatest 3.0.8 was provided. But the scalatest I had defined was 2.2.5. By changing the version of scalatest to 3.0.8, I was able to resolve this issue.

Hope this helps.

Sri21
  • 1
  • 2