Skip to content

Commit 7eb4042

Browse files
committed
Fix #8516: Keep correct parameter names when selecting in refined types
1 parent 800251d commit 7eb4042

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,16 @@ object Types {
673673
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
674674
}
675675
else
676-
pdenot & (
676+
val joint = pdenot & (
677677
new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId), pre),
678678
pre,
679679
safeIntersection = ctx.base.pendingMemberSearches.contains(name))
680+
joint match
681+
case joint: SingleDenotation
682+
if rinfo.isInstanceOf[MethodOrPoly] && rinfo <:< joint.info =>
683+
joint.derivedSingleDenotation(joint.symbol, rinfo)
684+
case _ =>
685+
joint
680686
}
681687

682688
def goApplied(tp: AppliedType, tycon: HKTypeLambda) =

tests/pos/i8516.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val x: Function1[Int, Int] { def apply(arg: Int): Int } = x => x
2+
val x1 = x
3+
val y = x.apply(arg = 1)

0 commit comments

Comments
 (0)