Skip to content

Commit 2a6ea6a

Browse files
committed
Include companion objects of abstract types in implicit scope
1 parent 352ff58 commit 2a6ea6a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,14 @@ trait ImplicitRunInfo { self: Run =>
478478
*
479479
* - If `tp` is a class reference, S contains a reference to the companion object of the class,
480480
* if it exists, as well as the implicit scopes of all of `tp`'s parent class references.
481-
* - If `tp` is an opaque type alias `p.A` of type `tp'`, S contains a reference to an object `A` defined in the
482-
* same scope as the opaque type, if it exists, as well as the implicit scope of `tp'`.
483-
* - If `tp` is a reference `p.T` to a class or opaque type alias, S also contains all object references
484-
* on the prefix path `p`. Under Scala-2 mode, package objects of package references on `p` also
485-
* count towards the implicit scope.
486-
* - If `tp` is an alias of `tp'`, S contains the implicit scope of `tp'`.
481+
* - If `tp` is an opaque type alias or abstract type `p.A`, S contains a reference to an
482+
* object `A` defined in the same scope as type `A`, if it exists, as well as
483+
* the implicit scope of `tp`s upper bound.
484+
* - If `tp` is a reference `p.T` to a class, an opaque type alias, or an abstract type,
485+
* S also contains all object references on the prefix path `p`.
486+
* Under Scala-2 mode, package objects of package references on `p` also count
487+
* towards the implicit scope.
488+
* - If `tp` is a (non-opaque) alias of `tp'`, S contains the implicit scope of `tp'`.
487489
* - If `tp` is some other type, its implicit scope is the union of the implicit scopes of
488490
* its parts (parts defined as in the spec).
489491
*
@@ -501,7 +503,8 @@ trait ImplicitRunInfo { self: Run =>
501503
/** Is `sym` an anchor type for which givens may exist? Anchor types are classes,
502504
* opaque type aliases, and abstract types, but not type parameters
503505
*/
504-
def isAnchor(sym: Symbol) = sym.isClass && !sym.is(Package) || sym.isOpaqueAlias
506+
def isAnchor(sym: Symbol) =
507+
sym.isClass && !sym.is(Package) || sym.is(DeferredType)
505508

506509
def anchors(tp: Type): List[Type] = tp match {
507510
case tp: NamedType if isAnchor(tp.symbol) => tp :: Nil

0 commit comments

Comments
 (0)