diff --git a/build.sbt b/build.sbt index 06210542..31e89f3f 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ val dottyVersion = "3.3.3" -//val dottyVersion = "3.4.2-RC1-bin-SNAPSHOT" +//val dottyVersion = "3.5.0-RC1-bin-SNAPSHOT" ThisBuild/version := "0.9.22-SNAPSHOT" diff --git a/compiler-plugin/src/main/scala/cps/plugin/CpsChangeSymbols.scala b/compiler-plugin/src/main/scala/cps/plugin/CpsChangeSymbols.scala index 6d7e4755..efb5f8c8 100644 --- a/compiler-plugin/src/main/scala/cps/plugin/CpsChangeSymbols.scala +++ b/compiler-plugin/src/main/scala/cps/plugin/CpsChangeSymbols.scala @@ -54,7 +54,7 @@ trait CpsChangeSymbols { //sym case None => sym.info match - case mt0: MethodOrPoly if (!sym.isAnonymousFunction) => + case mt0: MethodOrPoly if (!sym.isAnonymousFunction && !sym.hasAnnotation(Symbols.requiredClass("cps.plugin.annotation.CpsNotChange"))) => val timeTravelContext = summon[Context].fresh.setPhase(firstTransformPhase) val cpsDirectSym = CpsTransformHelper.cpsDirectAliasSymbol(using timeTravelContext) val oldSym = sym.current(using timeTravelContext) diff --git a/compiler-plugin/src/main/scala/cps/plugin/PhaseSelectAndGenerateShiftedMethods.scala b/compiler-plugin/src/main/scala/cps/plugin/PhaseSelectAndGenerateShiftedMethods.scala index 43b7fec0..98056856 100644 --- a/compiler-plugin/src/main/scala/cps/plugin/PhaseSelectAndGenerateShiftedMethods.scala +++ b/compiler-plugin/src/main/scala/cps/plugin/PhaseSelectAndGenerateShiftedMethods.scala @@ -83,7 +83,7 @@ class PhaseSelectAndGenerateShiftedMethods(selectedNodes: SelectedNodes) extends def annotateTopMethodWithSelectKind(tree: tpd.Tree)(using Context): Boolean = { lazy val cpsTransformedAnnot = Symbols.requiredClass("cps.plugin.annotation.CpsTransformed") tree match - case dd: DefDef => + case dd: DefDef if (!dd.symbol.hasAnnotation(Symbols.requiredClass("cps.plugin.annotation.CpsNotChange"))) => val optKind = SelectedNodes.detectDefDefSelectKind(dd) optKind match case Some(kind) => diff --git a/compiler-plugin/src/main/scala/cps/plugin/RemoveScaffolding.scala b/compiler-plugin/src/main/scala/cps/plugin/RemoveScaffolding.scala index 02e01724..d3f2147a 100644 --- a/compiler-plugin/src/main/scala/cps/plugin/RemoveScaffolding.scala +++ b/compiler-plugin/src/main/scala/cps/plugin/RemoveScaffolding.scala @@ -37,7 +37,6 @@ trait RemoveScaffolding { // (it created in erasure after uncarrying (preserve carrying form of method)) tree.rhs match case treeBlock@Block(List(ddef:DefDef), Closure(env,meth,tpe)) if meth.symbol == ddef.symbol => - println(s"closure found, ddef.rhs=${ddef.rhs}") ddef.rhs match case Apply(fn, args) => fn.symbol.getAnnotation(Symbols.requiredClass("cps.plugin.annotation.CpsTransformed")) match @@ -116,8 +115,6 @@ trait RemoveScaffolding { override def transformIdent(tree: Ident)(using Context): Tree = { if (tree.symbol.hasAnnotation(Symbols.requiredClass("cps.plugin.annotation.CpsTransformed"))) then - println(s"RemoveScaffolding::Ident, ${tree.show} has CpsTransformed annotation: ${tree.symbol.showFullName}") - println(s"tree.tpe.widen=${tree.tpe.widen.show}, tree.symbol.info.widen=${tree.symbol.info.widen}") ref(tree.symbol).withSpan(tree.span) else tree diff --git a/compiler-plugin/src/main/scala/cps/plugin/forest/ApplyTransform.scala b/compiler-plugin/src/main/scala/cps/plugin/forest/ApplyTransform.scala index 31653186..9f7e6003 100644 --- a/compiler-plugin/src/main/scala/cps/plugin/forest/ApplyTransform.scala +++ b/compiler-plugin/src/main/scala/cps/plugin/forest/ApplyTransform.scala @@ -367,13 +367,14 @@ object ApplyTransform { } val fullOrigin = if (argss.isEmpty) origin else argss.last.origin Log.trace(s"parseSyncFunPureApplication: plainTree=${plainTree.show}", nesting) - val retval = adoptCallMode(fullOrigin, plainTree, owner, argss, callMode) + val retval = adoptCallMode(fullOrigin, plainTree, fun.symbol, owner, argss, callMode, nesting) Log.trace(s"parseSyncFunPureApplication: retval=${retval.show}", nesting) retval } - def adoptCallMode(origin: Tree, plainTree: Tree, owner: Symbol, argss: List[ApplyArgList], callMode: FunCallMode)(using Context, CpsTopLevelContext): CpsTree = { - if (argss.exists(_.containsDirectContext) ) { + def adoptCallMode(origin: Tree, plainTree: Tree, funSym: Symbol, owner: Symbol, argss: List[ApplyArgList], callMode: FunCallMode, nesting: Int)(using Context, CpsTopLevelContext): CpsTree = { + Log.trace(s"adoptCallMode: plainTree=${plainTree.show}, callMode=${callMode} funSym=${funSym}", nesting) + if (argss.exists(_.containsDirectContext) && !funSym.hasAnnotation(Symbols.requiredClass("cps.plugin.annotation.CpsNotChange"))) { val directContextArg = argss.find(_.containsDirectContext).flatMap(_.findDirectContext).get val adoptedTree = directContextArg match case dc@CpsDirectHelper.ByInclusionCall(tf,tg,fctx,fgincl) => @@ -726,7 +727,11 @@ object ApplyTransform { } case _ => pureReply val fullOrigin = if (argss.isEmpty) origin else argss.last.origin - val lastCpsTree = adoptCallMode(fullOrigin, pureReply, owner, argss, callMode) + val funSymbol = fun match + case NonShiftedFun(tree) => tree.symbol + case ShiftedFun(origin, obj, method, targs, additionalArgs, canBeOverloaded, callShouldBeInlined, shape) => + obj.tpe.member(method).symbol + val lastCpsTree = adoptCallMode(fullOrigin, pureReply, funSymbol, owner, argss, callMode, nesting) val nApplyCpsTree = genPrefixes(argss, lastCpsTree) val retval = nApplyCpsTree Log.trace(s"genApplication result: ${retval.show}", nesting) diff --git a/compiler-plugin/src/test/scala/cc/Test22cc.scala b/compiler-plugin/src/test/scala/cc/Test22cc.scala index 30db5d7c..eec3118a 100644 --- a/compiler-plugin/src/test/scala/cc/Test22cc.scala +++ b/compiler-plugin/src/test/scala/cc/Test22cc.scala @@ -6,7 +6,7 @@ import org.junit.{Ignore, Test} class Test22cc { @Test - @Ignore // yet not working + //@Ignore // yet not working def testCompileContextExtractor() = { val inDir = "testdata/set22cc/m1" diff --git a/compiler-plugin/src/test/scala/cc/Test4Match.scala b/compiler-plugin/src/test/scala/cc/Test4Match.scala index cb25b72a..32c819f4 100644 --- a/compiler-plugin/src/test/scala/cc/Test4Match.scala +++ b/compiler-plugin/src/test/scala/cc/Test4Match.scala @@ -14,7 +14,7 @@ class Test4Match { val reporter = dotcInvocations.compileFilesInDir( "testdata/set4/m1", - "testdata/set4/m1/target") + "testdata/set4/m1-target") println("summary: " + reporter.summary) @@ -30,7 +30,7 @@ class Test4Match { val reporter = dotcInvocations.compileFilesInDir( "testdata/set4/m2", - "testdata/set4/m2/target") + "testdata/set4/m2-target") println("summary: " + reporter.summary) @@ -46,7 +46,7 @@ class Test4Match { val (code, output) = dotcInvocations.compileAndRunFilesInDirJVM( "testdata/set4/m3", - "testdata/set4/m3/target", + "testdata/set4/m3-target", "cpstest.s4.m3.Test4m3" ) diff --git a/compiler-plugin/testdata/set22cc/m1/CustomContext.scala b/compiler-plugin/testdata/set22cc/m1/CustomContext.scala index e434d272..c14e50e3 100644 --- a/compiler-plugin/testdata/set22cc/m1/CustomContext.scala +++ b/compiler-plugin/testdata/set22cc/m1/CustomContext.scala @@ -46,7 +46,7 @@ trait JSAsyncContext extends CpsTryMonadContext[JSAsync] { } @experimental -//@CpsNotChange +@CpsNotChange given jsAsyncFromDirect(using direct: CpsDirect[JSAsync]): JSAsyncContext = direct.context.asInstanceOf[JSAsyncContext]