Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation error when mocking classes defined inside traits #198

Open
vglushak opened this issue Aug 31, 2017 · 1 comment
Open

compilation error when mocking classes defined inside traits #198

vglushak opened this issue Aug 31, 2017 · 1 comment

Comments

@vglushak
Copy link

vglushak commented Aug 31, 2017

ScalaMock Version (e.g. 3.5.0)

3.5.0

Scala Version (e.g. 2.12)

2.11

Runtime (JVM or JS)

JVM

Please describe the expected behavior of the issue

Mock should be created correctly. No exceptions thrown.

Please provide a description of what actually happens

Compilation exception is thrown when pass as parameter a List of internal classes.

[error] method method overrides nothing.
[error] Note: the super classes of <$anon: services.assessmentcentre.Some> contain the following, non final members named method:
[error] def method: ((i: Long, p: List[_10.Param])Unit) forSome { val _10: services.assessmentcentre.Some{val mock$special$mockName: String; override def method(i: Long,p: List[Some.this.Param]): Unit; val mock$method$0: org.scalamock.function.MockFunction2[Long,List[Some.this.Param],Unit]} }
[error]     val mockSome = mock[Some]
[error]                        ^
[error] one error found
[error] (test:compileIncremental) Compilation failed

Reproducible Test Case

trait Some {
  case class Param(name: String)
  def method(i: Long, p: List[Param]): Unit = ???
}

// in test
val mockSome = mock[Some] 
// will fail to compile

Woraround:
Move Param case class outside or at least to object with the same name.

@vglushak vglushak changed the title [internal classes as parameters] the super classes of Some contain the following, non final members named method compilation error when mocking classes defined inside traits Aug 31, 2017
@barkhorn
Copy link
Collaborator

barkhorn commented Sep 2, 2017

Thanks for raising this.
There are some patterns where the macro based mocks struggle and this looks like another bug related to this - meaning it will be hard if not impossible to fix before our switch to scala.meta.
Can you check if you have more success using the Proxy mocks?
Also, you may want to upgrade to 3.6.0.

@barkhorn barkhorn added the ready label Sep 2, 2017
@barkhorn barkhorn added this to the v4.0.0 milestone Sep 25, 2017
@barkhorn barkhorn modified the milestones: v4.0.0, v4.1.0 Oct 29, 2017
@barkhorn barkhorn modified the milestones: v4.1.0, v4.2.0 Feb 17, 2018
@barkhorn barkhorn modified the milestones: v4.2.0, v4.3.0 Apr 21, 2019
@barkhorn barkhorn removed the ready label Apr 21, 2019
@barkhorn barkhorn removed this from the v4.3.0 milestone Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants