Skip to content

Commit 73aaf2a

Browse files
smartertgodzik
authored andcommitted
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 [Cherry-picked f7259cf]
1 parent dba8eaa commit 73aaf2a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,7 @@ trait Applications extends Compatibility {
23082308
if t.exists && alt.symbol.exists then
23092309
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
23102310
val mappedSym = alt.symbol.asTerm.copy(info = t)
2311+
mappedSym.annotations = alt.symbol.annotations
23112312
mappedSym.rawParamss = trimmed
23122313
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
23132314
case Some((pre, prevSkipped)) =>

tests/pos/i21410c.scala

Lines changed: 11 additions & 0 deletions
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)