Skip to content

Import exported function from a library loses the default parameters #17930

Closed
@JD557

Description

@JD557

Compiler version

3.3.0

Minimized code

lib.scala:

//> using scala "3.3.0"
//> using publish.name "defaultstest"
//> using publish.organization "eu.joaocosta"
//> using publish.version "0.1.0-SNAPSHOT"

package eu.joaocosta.defaultstest

object Foo {
  def foo(x: Int, y: Int = 5): Int = x + y
}

object Bar {
  export Foo.*
}

object App {
  println(Bar.foo(2)) // Works
}

Published with scala-cli --power publish local .\lib.scala

app.sc

//> using scala "3.3.0"
//> using lib "eu.joaocosta::defaultstest::0.1.0-SNAPSHOT"

import eu.joaocosta.defaultstest._

println(Foo.foo(2)) // Works
println(Bar.foo(2)) // Fails with "missing argument for parameter y of method foo in object Bar: (x: Int, y: Int): Int"

Output

[error] .\app.sc:7:9
[error] missing argument for parameter y of method foo in object Bar: (x: Int, y: Int): Int
[error] println(Bar.foo(2)) // Fails with "missing argument for parameter y of method foo in object Bar: (x: Int, y: Int): Int"
[error]         ^^^^^^^^^^

Expectation

The code should compile, using the default methods (same behavior as Foo.foo(2))

Notes

This seems very similar to #15031, although in my case the problem happens when importing a library.
No amount of clean/compile seems to fix it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions