Trying to understand IDEA Scala error

In IDEA 2017.1.2, I have the following failure:

When using ScalaMock, given, in part, from com.typesafe.config.Config.java:
public interface Config extends ConfigMergeable {
String getString(String path);
}

and in part, from com.rabbitmq.client.Connection.java:
public interface Connection extends ShutdownNotifier, Closeable {
Channel createChannel() throws IOException;
}

That this compiles:
class MySpec extends FlatSpec with Matchers with MockFactory {
private val mockConfig = mock[Config]
(mockConfig.getString _).expects("myhost").returning("test_host").anyNumberOfTimes
}

But this errs with 'Cannot resolve symbol createChannel'?
class MySpec extends FlatSpec with Matchers with MockFactory {
private val mockChannel = mock[Channel]
private val mockConnection = mock[Connection]
(mockConnection.createChannel _).expects().returning(mockChannel).anyNumberOfTimes
}


Everything seems the same to me, so perhaps I'm just missing something.

评论操作 固定链接

Is this in an sbt project? Does it compile with sbt? Are you able to share an example project with this problem?

Thanks

0
评论操作 固定链接

It's sbt, yes. The weird thing in sbt is that the code provided compiles under sbt, but fails when it runs:

scala.MatchError: Failure(org.scalatest.exceptions.TestFailedException: Unexpected call: <mock-3> Connection.createChannel()

so, it doesn't complain at compile time, but the method mock doesn't get registered, either.

As far as an example is concerned, there's working code and failing code provided with the original question. What's missing that you would like to see? I can't share the whole project.

0
评论操作 固定链接

The issue sounds like it might be a problem with the import in IDEA, or something related to dependencies or indexes. Just from the code snippets I won't be able to reproduce the failure and figure out what causes it or how to fix it.

So I can only give you some general hints to try:

  • reimport/refresh the project
  • try File / Invalidate Caches and Restart
0
评论操作 固定链接

Okay, tried those with no success. I'll create a new project to try reproducing the error.

0
评论操作 固定链接

Justin, thanks for your patience. Have a look at https://github.com/DonBranson/scala_debug.

0
评论操作 固定链接

I see that message is still pending approval, presumably a result of the URL. The project is on github, at DonBranson/scala_debug.

0

请先登录再写评论。