Skip to content
Open
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
if !overridden.is(Deferred) then fwdMeth.setFlag(Override)
DefDef(fwdMeth, ref(fn).appliedToArgss(_))
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code relies on evaluation order: typeMembers are entered via .entered before calling fwdMeth.allOverriddenSymbols in forwarder, otherwise overridden-signature matching can miss type aliases (as in #24765). Please add a short comment (or refactor to make the ordering/side effect explicit) so a future cleanup doesn’t accidentally revert the fix by inlining/reordering the maps.

Suggested change
}
}
// Important: `typeMembers` must be entered before calling `allOverriddenSymbols` in `forwarder`,
// otherwise overridden-signature matching can miss type aliases (see scala/bug#24765).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure of the convention in this repo. I will commit this suggestion if the human reviewer asks for it

termForwarders.map((name, sym) => forwarder(name, sym)) ++
typeMembers.map((name, info) => TypeDef(newSymbol(cls, name, Synthetic, info).entered))
val typeDefs = typeMembers.map((name, info) => TypeDef(newSymbol(cls, name, Synthetic, info).entered))
termForwarders.map((name, sym) => forwarder(name, sym)) ++ typeDefs
}
}

Expand Down
12 changes: 12 additions & 0 deletions tests/pos/i24765.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import language.experimental.modularity

trait A[T]:
extension(t: T) def foo: T

trait B:
type Self
extension(t: Self) def foo: Self

given A[Int] = x => x // ok before

given Int is B = x => x // was: "cannot override an extension method"
Loading