Skip to content

implicitNotFound annotation is not inherited #10098

@prolativ

Description

@prolativ

Minimized code

@annotation.implicitNotFound("There's no Foo1")
trait Foo1

@annotation.implicitNotFound("There's no Foo2")
trait Foo2

trait Bar12 extends Foo1 with Foo2

trait Bar21 extends Foo2 with Foo1

object Bar {
  implicitly[Bar12]
  implicitly[Bar21]
}

Output

no implicit argument of type Bar12 was found for parameter ev of method implicitly in object DottyPredef

no implicit argument of type Bar21 was found for parameter ev of method implicitly in object DottyPredef

Expectation

There's no Foo2

There's no Foo1

According to the comment on scala.annotation.implicitNotFound:

The annotation is effectively inherited by subtypes if they are not annotated.

In scala 2.13 this works as described. Although not explicitly documented, the order of inheritance is taken into account there and it makes sense to keep this behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions