Compiler error when inline method as inline parameter

Welcome to Scala 3.3.0-RC4 (, Java Java HotSpot(TM) 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> class Wrapper:
     |   val values: Array[Double] = Array.ofDim(10)
     |   def notInline(index: Int): Double = values(index)
     |   inline def useInline(index: Int): Double = values(index)
// defined class Wrapper

scala> inline def getValue(inline get: Int => Double, inline index: Int): Double = get(index)
def getValue(get: Int => Double, index: Int): Double

scala> val w = new Wrapper
val w: Wrapper = Wrapper@31433df9

scala> getValue(w.values, 0)
val res0: Double = 0.0

scala> getValue(w.notInline, 0)
val res1: Double = 0.0

scala> getValue(w.useInline, 0)  // what's the problem :joy:
-- Error: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

1 |getValue(w.useInline, 0)
  |         ^^^^^^^^^^^
  |         missing arguments for method useInline in class Wrapper
1 error found

I read the docs and learned

Inline methods always have to be fully applied. … and the compiler would complain that arguments are missing.

(If the message said that, it would be an example of bracing clarity.)

(Oh wait, I have to save “bracing clarity” for a discussion about significant indentation.)

1 Like