Skip to content

Commit 478b97a

Browse files
oderskyDarkDimius
authored andcommitted
Fix rewriting of by-name class parameter accessors.
Like the corresponding parameters, these also need to be rewritten to function types.
1 parent 88d11fa commit 478b97a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/dotty/tools/dotc/transform/ElimByName.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package transform
44
import TreeTransforms._
55
import core.DenotTransformers._
66
import core.Symbols._
7+
import core.SymDenotations._
78
import core.Contexts._
89
import core.Types._
910
import core.Flags._
@@ -75,9 +76,12 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
7576
cpy.Apply(tree)(tree.fun, args1)
7677
}
7778

79+
private def becomesFunction(symd: SymDenotation)(implicit ctx: Context) =
80+
(symd is Param) || (symd is (ParamAccessor, butNot = Method))
81+
7882
override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo): Tree = {
7983
val origDenot = originalDenotation(tree)
80-
if ((origDenot is Param) && (origDenot.info.isInstanceOf[ExprType]))
84+
if (becomesFunction(origDenot) && (origDenot.info.isInstanceOf[ExprType]))
8185
tree.select(defn.Function0_apply).appliedToNone
8286
else tree
8387
}
@@ -98,6 +102,6 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
98102
}
99103

100104
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type =
101-
if (sym is Param) transformParamInfo(tp)
105+
if (becomesFunction(sym)) transformParamInfo(tp)
102106
else elimByNameParams(tp)
103107
}

0 commit comments

Comments
 (0)