zio-prelude icon indicating copy to clipboard operation
zio-prelude copied to clipboard

equalTo not working with the compile-time smart types

Open gurghet opened this issue 2 years ago • 0 comments

Scala 3.1.2 ZIO 2.0.0-RC6

object Five extends Newtype[Int]:
  override inline def assertion = equalTo(5)
Five(5)

results in

-- Error: ----------------------------------------------------------------------
1 |Five(5)
  |^^^^^^^
  | Assertion Failed 
  |
  |We were unable to read your assertion at compile-time.
  |
  |You must either define your assertion directly or refer to other inline definitions:
  |
  |    override inline def assertion = greaterThan(10) && lessThan(100).
  |
  |    or
  |
  |    inline def extracted = greaterThan(10) && lessThan(100).
  |    override inline def assertion = extracted.
  |            
  | This location contains code that was inlined from rs$line$20:1
1 error found

while

object Five extends Newtype[Int]:
  override inline def assertion = between(5,5)
Five(5)

compiles correctly.

gurghet avatar May 29 '22 13:05 gurghet