Skip to content

Commit

Permalink
Merge branch 'master-3.4.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
rssh committed May 26, 2024
2 parents e0e35e8 + 40d7777 commit ab50fb4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler-plugin/src/test/scala/cc/Test22cc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions compiler-plugin/src/test/scala/cc/Test4Match.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion compiler-plugin/testdata/set22cc/m1/CustomContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait JSAsyncContext extends CpsTryMonadContext[JSAsync] {
}

@experimental
//@CpsNotChange
@CpsNotChange
given jsAsyncFromDirect(using direct: CpsDirect[JSAsync]): JSAsyncContext =
direct.context.asInstanceOf[JSAsyncContext]

Expand Down

0 comments on commit ab50fb4

Please sign in to comment.