E082: Super Calls Not Allowed In Inlineable

This error is emitted when an inline method contains a call to super.

Method inlining prohibits calling superclass methods because when the method is inlined at the call site, the super reference would be ambiguous or invalid - it would no longer refer to the superclass of the defining class.


Example

class Parent:
  def greet: String = "Hello"

class Child extends Parent:
  inline def greetLoud: String = super.greet + "!"

Error

-- [E082] Syntax Error: example.scala:5:33 -------------------------------------
5 |  inline def greetLoud: String = super.greet + "!"
  |                                 ^^^^^
  |                     Super call not allowed in inlineable method greetLoud
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Method inlining prohibits calling superclass methods, as it may lead to confusion about which super is being called.
   -----------------------------------------------------------------------------

Solution

// Remove the inline modifier
class Parent:
  def greet: String = "Hello"

class Child extends Parent:
  def greetLoud: String = super.greet + "!"
// Or use a helper method for the super call
class Parent:
  def greet: String = "Hello"

class Child extends Parent:
  private def parentGreet: String = super.greet
  inline def greetLoud: String = parentGreet + "!"