Please sign in to comment.
Closes SI-6358. Move accessor generation for lazy vals to typers.
Until now lazy accessors were handled somehow special because their symbol was created in typers but the corresponding tree was only added in Refchecks. This irregularity caused serious problems for value classes. Also it now looks just better when lazy value is treated in a similar way as other fields. I needed to adapt reifier so that it handles the new implementation correctly. Previously it had to recreate lazy val only by removing defdef and renaming. Now we basically need to recreate lazy val from scratch. There is one minor change to cps plugin but that is still fine because lazy vals were never really part of the transformation. Some range positions needed to be fixed manually. We could do it at the creation time but that would require a lot more "if (symbol.isLazy)" conditions for MethodSyntheis and Symbol/Tree creation and would just unnecessary complicate api. If someone has a better idea, please speak up. Range positions changes were necessary because previously accessors were created at refchecks and they weren't checked by validator (even though they were wrong). This commit removes lazy val implementation restriction introduced for 2.10.0. (cherry-picked from 981424b)
- Loading branch information...
Showing with 179 additions and 95 deletions.
- +51 −10 src/compiler/scala/reflect/reify/phases/Reshape.scala
- +3 −0 src/compiler/scala/tools/nsc/transform/LazyVals.scala
- +52 −11 src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
- +2 −4 src/compiler/scala/tools/nsc/typechecker/Namers.scala
- +0 −4 src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala
- +10 −36 src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
- +9 −6 src/compiler/scala/tools/nsc/typechecker/Typers.scala
- +5 −1 src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
- +6 −3 src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
- +12 −6 src/reflect/scala/reflect/internal/Trees.scala
- +3 −5 test/files/continuations-neg/lazy.check
- +4 −8 test/files/neg/valueclasses-impl-restrictions.check
- +0 −1 test/files/neg/valueclasses-impl-restrictions.scala
- +6 −0 test/files/pos/t6358.scala
- +3 −0 test/files/run/reify_lazyunit.check
- +13 −0 test/files/run/reify_lazyunit.scala
Oops, something went wrong.