-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix: cast args when applying mockFunctionValDef in scala 3 #529
Conversation
|
||
trait Foo { | ||
def p[T <: Bar](gen: Seq[T], t: Seq[T] => Seq[String]): Seq[String] = t(gen) | ||
def q[T <: Bar](gen: Seq[T]): Seq[String] = gen.map(_.toString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method (q
) was already absolutely fine, it was only the above method p
that caused compilation failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked one more time.
Lets add some more simple methods in this trait and also I would change names of method and trait so they would correspond to what we are trying to achieve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, should have time tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah thinking about it would be good to have some
def overloaded(gen: Seq[C1], t: Seq[C1] => Seq[String]): Seq[String] = t(gen)
def overloaded(gen: Seq[C2], t: Seq[C2] => Seq[String]): Seq[String] = t(gen)
stuff wouldn't it...
@barkhorn anything I can/should do on this pr to help it on its way? |
hey, I think @goshacodes should review this. Happy to do the admin bits but i'm not that active on the project anymor |
Hi, looks good, lets merge |
Pull Request Checklist
Fixes
Whilst mocking a trait or class with a method that took a type parameter worked in scala 3 for many cases, it did not work when the type parameter was used as the input for a function arg to that method. The newly-added test case failed in those instances (i.e.
def p[T]
) with the following:This is a regression from scala 2
Purpose
This pr casts the args when passing them to the mock method implementation, which avoids the above error.
Background Context
This seemed the least intrusive way of getting the new test case to work