Skip to content

Commit f7259cf

Browse files
committed
Make Applications#resolveMapped preserve annotations
Overloading may create a temporary symbol via `Applications#resolveMapped`, but before this commit, this symbol did not carry the annotations from the original symbol. This meant in particular that `isInlineable` would always return false for them. This matters because during the course of overloading resolution we might call `ProtoTypes.Compatibility#constrainResult` which special-cases transparent inline methods. Fixes a regression in Monocle introduced in the previous commit. wip
1 parent 528d0f0 commit f7259cf

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -2503,6 +2503,7 @@ trait Applications extends Compatibility {
25032503
if t.exists && alt.symbol.exists then
25042504
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
25052505
val mappedSym = alt.symbol.asTerm.copy(info = t)
2506+
mappedSym.annotations = alt.symbol.annotations
25062507
mappedSym.rawParamss = trimmed
25072508
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
25082509
case Some((pre, prevSkipped)) =>

tests/pos/i21410c.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AppliedPIso[A, B]()
2+
case class User(age: Int)
3+
4+
object Test:
5+
extension [From, To](from: From)
6+
def focus(): AppliedPIso[From, From] = ???
7+
transparent inline def focus(inline lambda: (From => To)): Any = ???
8+
9+
10+
val u = User(1)
11+
val ap: AppliedPIso[User, User] = u.focus(_.age) // error

0 commit comments

Comments
 (0)