-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add missing dealias in isContextFunctionRef #15742
Conversation
tests/pos/i15738.scala
Outdated
@@ -0,0 +1,16 @@ | |||
object Test { | |||
trait Transaction | |||
type Transactional[T] = (Transaction) ?=> T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe (t: Transaction)
? This test as-is already passes on 3.1.3
How I fixed it: This was a single line fix, but it took a bit to find out what needed fixing. I first played around with the example extensively changing various elements and dropping non-essential code (like the summon statements). I then found out that the difference was whether the CFT was expressed as a simple function I saw that in the case where it worked the
to the tree copier expression that created the watched out for node with number 339. That gave me node 338, and watching for his node with if ((implicitFun || caseCompanion) &&
!isApplyProto(pt) &&
pt != AssignProto &&
!ctx.mode.is(Mode.Pattern) &&
!ctx.isAfterTyper &&
!ctx.isInlineContext) {
typr.println(i"insert apply on implicit $tree")
val sel = untpd.Select(untpd.TypedSplice(tree), nme.apply).withAttachment(InsertedApply, ()) I then instrumented that code showing various parts of the condition and ran it with both the good and the bad definition of def isContextFunctionRef(wtp: Type): Boolean = wtp match {
case RefinedType(parent, nme.apply, _) =>
isContextFunctionRef(parent) // apply refinements indicate a dependent CFT
case _ =>
val underlying = wtp.underlyingClassRef(refinementOK = false) // other refinements are not OK
defn.isContextFunctionClass(underlying.classSymbol)
} So, two branches, one for the dependent case (which is represented as a refinement), the other for the simple case. But if the whole thing was wrapped in an alias it did not work anymore. The toplevel case is not a ADDENDUM: In the end it turned out that the faulty method was not needed at all, since the functionality was already implemented correctly by |
It turns out the faulty method should not even have existed since it was trying to duplicate functionality defined elsewhere.
Fixes #15738