diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-23 12:43:08 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 08:24:36 +0200 |
commit | 478b97a1cbc67af97bb8be98a36c5b8173898f2b (patch) | |
tree | dceb3e056ae50d641c0265ced5f81e740a32d096 | |
parent | 88d11fa21761d798baeb24b8002ddacade601b23 (diff) | |
download | dotty-478b97a1cbc67af97bb8be98a36c5b8173898f2b.tar.gz dotty-478b97a1cbc67af97bb8be98a36c5b8173898f2b.tar.bz2 dotty-478b97a1cbc67af97bb8be98a36c5b8173898f2b.zip |
Fix rewriting of by-name class parameter accessors.
Like the corresponding parameters, these also need to be rewritten to function types.
-rw-r--r-- | src/dotty/tools/dotc/transform/ElimByName.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/ElimByName.scala b/src/dotty/tools/dotc/transform/ElimByName.scala index 5925ffa72..e656c8438 100644 --- a/src/dotty/tools/dotc/transform/ElimByName.scala +++ b/src/dotty/tools/dotc/transform/ElimByName.scala @@ -4,6 +4,7 @@ package transform import TreeTransforms._ import core.DenotTransformers._ import core.Symbols._ +import core.SymDenotations._ import core.Contexts._ import core.Types._ import core.Flags._ @@ -75,9 +76,12 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform cpy.Apply(tree)(tree.fun, args1) } + private def becomesFunction(symd: SymDenotation)(implicit ctx: Context) = + (symd is Param) || (symd is (ParamAccessor, butNot = Method)) + override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo): Tree = { val origDenot = originalDenotation(tree) - if ((origDenot is Param) && (origDenot.info.isInstanceOf[ExprType])) + if (becomesFunction(origDenot) && (origDenot.info.isInstanceOf[ExprType])) tree.select(defn.Function0_apply).appliedToNone else tree } @@ -98,6 +102,6 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform } def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = - if (sym is Param) transformParamInfo(tp) + if (becomesFunction(sym)) transformParamInfo(tp) else elimByNameParams(tp) } |