From b7c3c3551fd56fb75018f051666edd8558a98d66 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Tue, 7 Mar 2017 10:56:41 +0100 Subject: Fix #2054: @Static methods may access synthetic private methods stuff Due to way how we desugar lambdas, we can decide to make a lambda static Static methods could refer to those lambdas and we need to make them public --- compiler/src/dotty/tools/dotc/transform/MoveStatics.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/src/dotty/tools/dotc/transform') diff --git a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala index 5c2cd3145..2dde8ca31 100644 --- a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala +++ b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala @@ -9,6 +9,7 @@ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.core.NameOps._ import dotty.tools.dotc.core.{Flags, Names} import dotty.tools.dotc.core.Names.Name +import dotty.tools.dotc.core.Phases.Phase import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Types.MethodType import dotty.tools.dotc.transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo} @@ -19,6 +20,8 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform import tpd._ override def phaseName = "moveStatic" + // This phase moves methods around(in infortransform) so it may need to make other methods public + override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[ExpandPrivate]) def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = { if (sym.hasAnnotation(defn.ScalaStaticAnnot) && sym.owner.is(Flags.Module) && sym.owner.companionClass.exists) { -- cgit v1.2.3 From 3e5e276e26e12f43c66d0f4b190d43203a08efad Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 13 Mar 2017 10:34:26 +0100 Subject: Fix a stupid error in fix of #2054. --- compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala | 8 +++++++- compiler/src/dotty/tools/dotc/transform/MoveStatics.scala | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/transform') diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala b/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala index 83cd395ff..2841de401 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala @@ -3,7 +3,7 @@ package transform import core._ import dotty.tools.dotc.ast.tpd -import dotty.tools.dotc.core.DenotTransformers.{SymTransformer, IdentityDenotTransformer} +import dotty.tools.dotc.core.DenotTransformers.{IdentityDenotTransformer, SymTransformer} import Contexts.Context import Symbols._ import Scopes._ @@ -11,13 +11,16 @@ import Flags._ import StdNames._ import SymDenotations._ import Types._ + import collection.mutable import TreeTransforms._ import Decorators._ import ast.Trees._ import TreeTransforms._ import java.io.File.separatorChar + import ValueClasses._ +import dotty.tools.dotc.core.Phases.Phase /** Make private term members that are accessed from another class * non-private by resetting the Private flag and expanding their name. @@ -38,6 +41,9 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t override def phaseName: String = "expandPrivate" + // This phase moves methods around(in infortransform) so it may need to make other methods public + override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[MoveStatics]) + override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { tree match { case t: DefDef => diff --git a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala index 2dde8ca31..b0ee0930d 100644 --- a/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala +++ b/compiler/src/dotty/tools/dotc/transform/MoveStatics.scala @@ -20,9 +20,6 @@ class MoveStatics extends MiniPhaseTransform with SymTransformer { thisTransform import tpd._ override def phaseName = "moveStatic" - // This phase moves methods around(in infortransform) so it may need to make other methods public - override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[ExpandPrivate]) - def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = { if (sym.hasAnnotation(defn.ScalaStaticAnnot) && sym.owner.is(Flags.Module) && sym.owner.companionClass.exists) { sym.owner.asClass.delete(sym.symbol) -- cgit v1.2.3 From d45c09acb49c862f38d1de588abac3412876e32e Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Sat, 18 Mar 2017 10:43:44 +0100 Subject: fix typo in comment --- compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/transform') diff --git a/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala b/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala index 2841de401..8f99ef1d0 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala @@ -41,7 +41,7 @@ class ExpandPrivate extends MiniPhaseTransform with IdentityDenotTransformer { t override def phaseName: String = "expandPrivate" - // This phase moves methods around(in infortransform) so it may need to make other methods public + // This phase moves methods around (in infotransform) so it may need to make other methods public override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[MoveStatics]) override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { -- cgit v1.2.3