Skip to content

Commit

Permalink
address review: part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Nov 14, 2024
1 parent be8d0c6 commit ac35e2f
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 148 deletions.
7 changes: 1 addition & 6 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,8 @@ object Annotations {
assert(myTree != null)
myTree match {
case treeFn: (Context ?=> Tree) @unchecked =>
var result: Tree | Null = null
myTree = null
try
result = atPhaseBeforeTransforms(treeFn)
myTree = result
finally if result == null then
myTree = ctx ?=> treeFn(using ctx) // reset, if unit is suspended then it will re-enter this annotation
myTree = atPhaseBeforeTransforms(treeFn)
case _ =>
}
myTree.asInstanceOf[Tree]
Expand Down
18 changes: 5 additions & 13 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ class TreeUnpickler(reader: TastyReader,
case ex: Exception => fail(ex)
}

class TreeReader(val reader: TastyReader, inInlineBody: Boolean = false) {
class TreeReader(val reader: TastyReader) {
import reader.*

def forkAt(start: Addr, inInlineBody: Boolean = false): TreeReader =
new TreeReader(subReader(start, endAddr), inInlineBody)
def forkAt(start: Addr): TreeReader = new TreeReader(subReader(start, endAddr))

def fork: TreeReader = forkAt(currentAddr, inInlineBody)
def fork: TreeReader = forkAt(currentAddr)

def skipParentTree(tag: Int): Unit = {
if tag == SPLITCLAUSE then ()
Expand Down Expand Up @@ -696,7 +695,7 @@ class TreeUnpickler(reader: TastyReader,
val ctx1 = localContext(sym)(using ctx0).addMode(Mode.ReadPositions)
inContext(sourceChangeContext(Addr(0))(using ctx1)) {
// avoids space leaks by not capturing the current context
forkAt(rhsStart, inInlineBody = true).readTree()
forkAt(rhsStart).readTree()
}
})
goto(start)
Expand Down Expand Up @@ -1585,11 +1584,7 @@ class TreeUnpickler(reader: TastyReader,
val denot = inContext(ctx.addMode(Mode.ResolveFromTASTy)):
searchDenot // able to resolve Invisible members


val sel = makeSelect(qual, name, denot)
if denot == NoDenotation && inInlineBody && sel.denot.symbol.exists && sel.symbol.isDefinedInCurrentRun then
throw new ChangedMethodDenot(sel.denot.symbol)
sel
makeSelect(qual, name, denot)
case REPEATED =>
val elemtpt = readTpt()
SeqLiteral(until(end)(readTree()), elemtpt)
Expand Down Expand Up @@ -1896,9 +1891,6 @@ class TreeUnpickler(reader: TastyReader,

object TreeUnpickler {

/** Specifically thrown when a SELECTin was written to TASTy, i.e. is expected to resolve, and then doesn't. */
private[dotc] final class ChangedMethodDenot(val resolved: Symbol) extends Exception

/** Define the expected format of the tasty bytes
* - TopLevel: Tasty that contains a full class nested in its package
* - Term: Tasty that contains only a term tree
Expand Down
14 changes: 1 addition & 13 deletions compiler/src/dotty/tools/dotc/inlines/Inlines.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import staging.StagingLevel
import collection.mutable
import reporting.{NotConstant, trace}
import util.Spans.Span
import dotty.tools.dotc.core.tasty.TreeUnpickler

/** Support for querying inlineable methods and for inlining calls to such methods */
object Inlines:
Expand Down Expand Up @@ -159,18 +158,7 @@ object Inlines:
else if enclosingInlineds.length < ctx.settings.XmaxInlines.value && !reachedInlinedTreesLimit then
val body =
try bodyToInline(tree.symbol) // can typecheck the tree and thereby produce errors
catch
case _: MissingInlineInfo => throw CyclicReference(ctx.owner)
case err: TreeUnpickler.ChangedMethodDenot =>
// tested in sbt-test/tasty-compat/add-param-unroll2/a_v3/A.scala
if err.resolved.source == ctx.source then
report.error(em"""cannot inline ${tree.symbol}:
| The definition of ${err.resolved.showLocated}, defined in the current file, has changed incompatibly.
| Try inlining from a different file.""", tree.srcPos)
EmptyTree
else
// Tested in sbt-test/tasty-compat/add-param-unroll2/a_v3_2/C.scala
ctx.compilationUnit.suspend("suspending in case of possible generated methods")
catch case _: MissingInlineInfo => throw CyclicReference(ctx.owner)
new InlineCall(tree).expand(body)
else
ctx.base.stopInlining = true
Expand Down
10 changes: 0 additions & 10 deletions sbt-test/tasty-compat/add-param-unroll2/a_v1/A.scala

This file was deleted.

8 changes: 0 additions & 8 deletions sbt-test/tasty-compat/add-param-unroll2/a_v2/B.scala

This file was deleted.

19 changes: 0 additions & 19 deletions sbt-test/tasty-compat/add-param-unroll2/a_v3/A.scala

This file was deleted.

10 changes: 0 additions & 10 deletions sbt-test/tasty-compat/add-param-unroll2/a_v3_2/A.scala

This file was deleted.

9 changes: 0 additions & 9 deletions sbt-test/tasty-compat/add-param-unroll2/a_v3_2/C.scala

This file was deleted.

38 changes: 0 additions & 38 deletions sbt-test/tasty-compat/add-param-unroll2/build.sbt

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions sbt-test/tasty-compat/add-param-unroll2/test

This file was deleted.

0 comments on commit ac35e2f

Please sign in to comment.