Skip to content

Commit 7c94e5c

Browse files
authored
Merge pull request #6865 from dotty-staging/fix-ift-lhs
Don't eta-expand implicit functions on the LHS of assignments
2 parents 11acdd9 + bcddf70 commit 7c94e5c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object Typer {
4949
*/
5050
enum BindingPrec {
5151
case NothingBound, PackageClause, WildImport, NamedImport, Definition
52-
52+
5353
def isImportPrec = this == NamedImport || this == WildImport
5454
}
5555

@@ -655,7 +655,7 @@ class Typer extends Namer
655655
case lhs =>
656656
val locked = ctx.typerState.ownedVars
657657
val lhsCore = typedUnadapted(lhs, AssignProto, locked)
658-
def lhs1 = typed(untpd.TypedSplice(lhsCore), WildcardType, locked)
658+
def lhs1 = adapt(lhsCore, AssignProto, locked)
659659

660660
def reassignmentToVal =
661661
errorTree(cpy.Assign(tree)(lhsCore, typed(tree.rhs, lhs1.tpe.widen)),
@@ -2983,6 +2983,7 @@ class Typer extends Namer
29832983
if (isImplicitFunctionRef(wtp) &&
29842984
!untpd.isContextualClosure(tree) &&
29852985
!isApplyProto(pt) &&
2986+
pt != AssignProto &&
29862987
!ctx.mode.is(Mode.Pattern) &&
29872988
!ctx.isAfterTyper) {
29882989
typr.println(i"insert apply on implicit $tree")

tests/pos/ift-assign.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Context
2+
3+
object Test {
4+
var f: given Context => String = given _ => ""
5+
6+
f = f
7+
8+
}

0 commit comments

Comments
 (0)