You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Always exclude package objects from the implicit scope
Unlike Scala 2, in Dotty when constructing the implicit scope for a type
`pkgA.Foo`, we do not include the main package object (`pkgA.package`).
We don't include the package objects we define for top-level definitions
either.
However, when constructing the implicit scope for a type defined in a
package object (e.g. `pkgA.foo$package.Foo`), we did including the
implicits defined in the enclosing package object. This is problematic
because at the source-level it's hard to distinguish which definitions
will be included in the package object. For example, in the testcase
included in this commit, `summon[ToString[A.AB]]` used to succeed
because both the type `AB` and the given alias for `ToString[AB]` ended
up wrapped in a package object, but the other summon calls failed
because classes and given instances are not wrapped in a package object.
To fix this inconsistency, we now always exclude package objects from
the implicit scope, even for types defined in the package objects itself.
The companion object of classes and opaque types stays the preferred
place to put implicit definitions and is not affected by this change.
0 commit comments