Wildcard export and export omitter in Scala 3

Hi all,
I am trying out the export clause in Scala 3 (v3.2.2). Here it is mentioned that we can uses _ to omit a particular member from exported and it will not be accessible by further wildcard exports. But I am still able to access it. What am I doing wrong here?

class Foo {
  def test = "hello"
  def test2 = "hello 2"
}
class Bar {
  private val foo = new Foo
  export foo.test2 as _
  export foo.*
}
class FooBar {
  val bar = new Bar
  bar.test
  bar.test2 //this should not compile?
}

When you combine both export statements into a single statement, it works as expected:

export foo.{test2 as _, *}

demo-scastie

2 Likes

I think i got confused by this statement in the doc earlier:

An omitting selector x as _ prevents x from being aliased by a subsequent wildcard selector.

Thanks @cestLaVie for quick reply :smile:

import has the same syntax and quirk, and invites the same question.

One might have hoped for import syntax reform, as has been discussed but somehow did not progress.

A reformed syntax might read more naturally, import q.* except Foo, Bar.

Some good explanations of the status quo.

4 Likes