# Is it possible to export top level Opaque Types in Scala 3?

**URL:** <https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136>\
**Category:** Dotty\
**Created:** [June 16, 2021, 5:44pm UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136 "2021-06-16T17:44:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pme123](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/pme123/32/1203_2.png) [@pme123](https://contributors.scala-lang.org/u/pme123)\
**Post date:** [June 16, 2021, 5:44pm UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136/1 "2021-06-16T17:44:34Z")

</div>

I asked this question on Stackoverflow and got no answer. Here it is:

I am playing with the Scala 3 feature [Export Clauses](https://dotty.epfl.ch/docs/reference/other-new-features/export.html).

Everything works, except of _opaque types_.

I could not find any restrictions on them. My Opaque Type:

```auto
opaque type BpmnPath = String

object BpmnPath:
  def apply(path: String): BpmnPath = path

```

My exports:

```auto
package camundala

export model.BpmnPath

```

Usage:

```auto
package camundala
package dsl

trait DSL :

  def path(pathStr: String): BpmnPath =
    BpmnPath(pathStr)

```

This gives me the following exception:

```auto
Found: camundala.model.exports$package.BpmnPath
Required: camundala.BpmnPath²

where: BpmnPath is a type in package object exports$package
          BpmnPath² is a type in package object exports$package which is an alias of camundala.model.BpmnPath

```

Original Question on [Stackoverflow](https://stackoverflow.com/questions/67958398/is-it-possible-to-export-top-level-opaque-types-in-scala-3)

---

<div class="post-metadata">

**Author:** ![bishabosha](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bishabosha/32/3101_2.png) [@bishabosha](https://contributors.scala-lang.org/u/bishabosha)\
**Post date:** [June 16, 2021, 7:07pm UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136/2 "2021-06-16T19:07:41Z")

</div>

Hi, this looks just like the bug [`export` of opaque type alias from another package leads to type mismatch · Issue #12168 · lampepfl/dotty · GitHub](https://github.com/lampepfl/dotty/issues/12168) which was fixed in Scala `3.0.1-RC1`, would you be able to try again with that?

---

<div class="post-metadata">

**Author:** ![pme123](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/pme123/32/1203_2.png) [@pme123](https://contributors.scala-lang.org/u/pme123)\
**Post date:** [June 16, 2021, 8:05pm UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136/3 "2021-06-16T20:05:26Z")

</div>

Thanks @bishabosha, `3.0.1-RC1` solves that problem - but I have now a new compilation problem:

```
export org.camunda.bpm.model.bpmn.{instance as cBpmnInstance}

```

Gives me:

```
no eligible member instance at org.camunda.bpm.model.bpmn
export org.camunda.bpm.model.bpmn.{instance as cBpmnInstance}

```

I get this for any package.

---

<div class="post-metadata">

**Author:** ![bishabosha](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/bishabosha/32/3101_2.png) [@bishabosha](https://contributors.scala-lang.org/u/bishabosha)\
**Post date:** [June 17, 2021, 12:43am UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136/4 "2021-06-17T00:43:40Z")

</div>

would you be able to open an issue at [GitHub - lampepfl/dotty: The Scala 3 compiler, also known as Dotty.](https://github.com/lampepfl/dotty/) with all the minimum code required to reproduce the error?

---

<div class="post-metadata">

**Author:** ![pme123](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/pme123/32/1203_2.png) [@pme123](https://contributors.scala-lang.org/u/pme123)\
**Post date:** [June 17, 2021, 4:39pm UTC](https://contributors.scala-lang.org/t/is-it-possible-to-export-top-level-opaque-types-in-scala-3/5136/5 "2021-06-17T16:39:22Z")

</div>

Looks like for renaming there is a restriction:

> **Restrictions:**  
> …  
> 3. Simple renaming exports like
> 
> ```auto
> export status as stat
> 
> ```
> 
> are not supported yet. They would run afoul of the restriction that the exported `a` cannot be already a member of the object containing the export. This restriction might be lifted in the future.

Interesting that this works with 3.0.0.

Or is this another case?
