Skip to content

Fix #8516: Keep correct parameter names when selecting in refined types #8529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2020
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
9 changes: 8 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,17 @@ object Types {
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
}
else
pdenot & (
val joint = pdenot & (
Copy link
Member

Choose a reason for hiding this comment

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

I guess there's no good way to handle parameter names when intersecting two method types?

And sorry about the off-topic remark, but I'm a bit surprised to see infix with multiple parameter lists, isn't that an anti-pattern? I see it was discussed on #4311 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should change the infix part.

new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId), pre),
pre,
safeIntersection = ctx.base.pendingMemberSearches.contains(name))
joint match
case joint: SingleDenotation
if rinfo.isInstanceOf[MethodOrPoly] && rinfo <:< joint.info =>
// use `rinfo` to keep the right parameter names for named args. See i8516.scala.
joint.derivedSingleDenotation(joint.symbol, rinfo)
case _ =>
joint
}

def goApplied(tp: AppliedType, tycon: HKTypeLambda) =
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i8516.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val x: Function1[Int, Int] { def apply(arg: Int): Int } = x => x
val x1 = x
val y = x.apply(arg = 1)