Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ class Namer { typer: Typer =>
newSymbol(cls, forwarderName, mbrFlags, mbrInfo, coord = span)

forwarder.info = avoidPrivateLeaks(forwarder)

// Add annotations at the member level
forwarder.addAnnotations(sym.annotations.filterConserve { annot =>
annot.symbol != defn.BodyAnnot
&& annot.symbol != defn.TailrecAnnot
Expand Down Expand Up @@ -1290,6 +1292,15 @@ class Namer { typer: Typer =>
foreachDefaultGetterOf(sym.asTerm,
getter => addForwarder(
getter.name.asTermName, getter.asSeenFrom(path.tpe), span))

// adding annotations at the parameter level
// TODO: This probably needs to be filtered to avoid adding some annotation
// such as MacroAnnotations
if sym.is(Method) then
for (orig, forwarded) <- sym.paramSymss.lazyZip(forwarder.paramSymss)
(origParameter, exportedParameter) <- orig.lazyZip(forwarded)
do
exportedParameter.addAnnotations(origParameter.annotations)
end addForwarder

def addForwardersNamed(name: TermName, alias: TermName, span: Span): Unit =
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i20127.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- [E172] Type Error: tests/neg/i20127.scala:13:9 ----------------------------------------------------------------------
13 | Foo.foo // error
| ^
| foo!
-- [E172] Type Error: tests/neg/i20127.scala:14:14 ---------------------------------------------------------------------
14 | FooClone.foo // error
| ^
| foo!
14 changes: 14 additions & 0 deletions tests/neg/i20127.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import scala.annotation.*

trait X

object Foo:
def foo(using @implicitNotFound("foo!") x: X) = "foo"

object FooClone:
export Foo.foo

object Main:
val n = 10
Foo.foo // error
FooClone.foo // error