# E4073

Cannot provide default implementation for traits from other packages.

This is a corollary of the [orphan rules of traits and types in
MoonBit](../packages.md#trait-implementations).
Default implementation can be seen as implementing the trait for all possible
types, including types defined within or outside of current package. Therefore,
it is only possible for default implementation to be defined in the package of
the trait, otherwise it would violate the orphan rules.

## Erroneous example

Suppose you have a trait `T` defined in package `a` in module `username/hello`:

`a/a.mbt`:

```{literalinclude} /sources/error_codes/E4073_error/top.mbt
:language: moonbit
```

And when you want to define a default implementation for the trait in another
package, say `b`:

`b/moon.pkg.json`:

```json
{
  "import": [
    "username/hello/a"
  ]
}
```

`b/b.mbt`:

```{literalinclude} /sources/error_codes/E4073_error/top_1.mbt
:language: moonbit
```

## Suggestion

To fix this error, you can move the definition of the trait and the default
implementation of this trait into the same package. Say you can move the trait
definition into package `b`:

`b/b.mbt`:

```{literalinclude} /sources/error_codes/E4073_fixed/top.mbt
:language: moonbit
```
