ScalaMock icon indicating copy to clipboard operation
ScalaMock copied to clipboard

only cast null constructor args for primitives

Open martijnhoekstra opened this issue 9 months ago • 6 comments

before, we tried to cast applied types to the type arguments, to capture context bounds. That fails for simple generic types that then get cast to the wrong type. However, that's all unnessecary: the only nulls we need to cast are primitives, which can't be passed as null. Anyting else doesn't need a cast at all

Pull Request Checklist

  • [x] I agree to licence my contributions under the MIT licence
  • [x] I have added copyright headers to new files
  • [x] I have added tests for any changed functionality

Fixes

Fixes #519

Purpose

Fix mocking classes with generic parameters. Before, mocking class Foo(x: Option[Int]) failed

Background Context

simplifying the casts by only doing them when needed simplifies thing significantly

References

martijnhoekstra avatar May 20 '24 16:05 martijnhoekstra