Skip to content

Exporting extension methods drops default arguments #14159

Closed
@dcascaval

Description

@dcascaval

Compiler version

3.1.0 (this also reproduces on the latest nightly as of 12/20)

Minimized code

object api:
  export impl.*

object impl:
  class Bar
  extension (rcv: Bar)
    def foo(a: Int) = ()
    def bar(a: Int, b: Boolean = false) = ()

object Test1:
  import api.*
  val value = (new Bar).bar(0) // Error

object Test2:
  import impl.*
  val value = (new Bar).bar(0) // Works

object Test3:
  import api.*
  val value = (new Bar).foo(0) // Works

Output

[error] 12 |  val value = (new Bar).bar(0) // Missing argument
[error]    |              ^^^^^^^^^^^^^^^^
[error]    |missing argument for parameter b of method bar in object api: (a: Int, b: Boolean): Unit

Expectation

Hit this case when exporting extension method through a facade object api from an implementation object impl. Since exporting normal extension methods (e.g. foo) works, I would also expect the method bar to export such that it can be called omitting the second argument and having it be filled in by the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions