Skip to content

Commit 3b0209c

Browse files
committed
typedUnApply#trySelectUnapply: small cleanup
Previously, `specificProto` was a def even though it is always called, this is because in cece884, the usages of `specificProto` and `genericProto` were swapped. We fix this by only defining the protos where they are used. Incidentally, this mean that the calls to UnapplyFunProto will use the correct Context inside `tryEither`, although in this case this shouldn't matter.
1 parent 08cd627 commit 3b0209c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
805805
* whereas overloaded variants need to have a conforming variant.
806806
*/
807807
def trySelectUnapply(qual: untpd.Tree)(fallBack: Tree => Tree): Tree = {
808-
val genericProto = new UnapplyFunProto(WildcardType, this)
809-
def specificProto = new UnapplyFunProto(selType, this)
810808
// try first for non-overloaded, then for overloaded ocurrences
811809
def tryWithName(name: TermName)(fallBack: Tree => Tree)(implicit ctx: Context): Tree =
812-
tryEither {
813-
implicit ctx => typedExpr(untpd.Select(qual, name), specificProto)
810+
tryEither { implicit ctx =>
811+
val specificProto = new UnapplyFunProto(selType, this)
812+
typedExpr(untpd.Select(qual, name), specificProto)
814813
} {
815814
(sel, _) =>
816-
tryEither {
817-
implicit ctx => typedExpr(untpd.Select(qual, name), genericProto)
815+
tryEither { implicit ctx =>
816+
val genericProto = new UnapplyFunProto(WildcardType, this)
817+
typedExpr(untpd.Select(qual, name), genericProto)
818818
} {
819819
(_, _) => fallBack(sel)
820820
}

0 commit comments

Comments
 (0)