Skip to content

Commit cfb4c9c

Browse files
committed
Simplify setup of DefDef and ValDef nodes
1 parent 9f5a466 commit cfb4c9c

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,22 +320,20 @@ extends tpd.TreeTraverser:
320320

321321
def traverse(tree: Tree)(using Context): Unit =
322322
tree match
323-
case tree: DefDef =>
323+
case tree @ DefDef(_, paramss, tpt: TypeTree, _) =>
324324
if isExcluded(tree.symbol) then
325325
return
326326
inContext(ctx.withOwner(tree.symbol)):
327327
if tree.symbol.isAnonymousFunction && tree.symbol.definedLocalRoot.exists then
328328
// closures that define parameters of type caps.Cap count as level owners
329329
tree.symbol.setNestingLevel(ctx.owner.nestingLevel + 1)
330-
tree.tpt match
331-
case tpt: TypeTree if tree.symbol.allOverriddenSymbols.hasNext =>
332-
tree.paramss.foreach(traverse)
333-
transformTT(tpt, boxed = false, exact = true, mapRoots = true)
334-
traverse(tree.rhs)
335-
//println(i"TYPE of ${tree.symbol.showLocated} = ${tpt.knownType}")
336-
case _ =>
337-
traverseChildren(tree)
338-
case tree @ ValDef(_, tpt: TypeTree, rhs) =>
330+
paramss.foreach(traverse)
331+
transformTT(tpt, boxed = false,
332+
exact = tree.symbol.allOverriddenSymbols.hasNext,
333+
mapRoots = true)
334+
traverse(tree.rhs)
335+
//println(i"TYPE of ${tree.symbol.showLocated} = ${tpt.knownType}")
336+
case tree @ ValDef(_, tpt: TypeTree, _) =>
339337
def containsCap(tp: Type) = tp.existsPart:
340338
case CapturingType(_, refs) => refs.isUniversal
341339
case _ => false
@@ -345,7 +343,7 @@ extends tpd.TreeTraverser:
345343
case _: InferredTypeTree => false
346344
case _: TypeTree => containsCap(expandAliases(tree.tpe))
347345
case _ => false
348-
val mapRoots = rhs match
346+
val mapRoots = tree.rhs match
349347
case possiblyTypedClosureDef(ddef) if !mentionsCap(rhsOfEtaExpansion(ddef)) =>
350348
ddef.symbol.setNestingLevel(ctx.owner.nestingLevel + 1)
351349
// Toplevel closures bound to vals count as level owners

0 commit comments

Comments
 (0)