@@ -243,20 +243,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
243243 case y => y
244244 }
245245
246- /** The largest subset of {NoInits, PureInterface} that a
247- * trait or class enclosing this statement can have as flags.
248- */
249- def defKind (tree : Tree )(implicit ctx : Context ): FlagSet = unsplice(tree) match {
250- case EmptyTree | _ : Import => NoInitsInterface
251- case tree : TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
252- case tree : DefDef =>
253- if (tree.unforcedRhs == EmptyTree &&
254- tree.vparamss.forall(_.forall(_.rhs.isEmpty))) NoInitsInterface
255- else NoInits
256- case tree : ValDef => if (tree.unforcedRhs == EmptyTree ) NoInitsInterface else EmptyFlags
257- case _ => EmptyFlags
258- }
259-
260246 /** The largest subset of {NoInits, PureInterface} that a
261247 * trait or class with these parents can have as flags.
262248 */
@@ -266,12 +252,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
266252 case _ :: parents1 => parentsKind(parents1)
267253 }
268254
269- /** The largest subset of {NoInits, PureInterface} that a
270- * trait or class with this body can have as flags.
271- */
272- def bodyKind (body : List [Tree ])(implicit ctx : Context ): FlagSet =
273- (NoInitsInterface /: body)((fs, stat) => fs & defKind(stat))
274-
275255 /** Checks whether predicate `p` is true for all result parts of this expression,
276256 * where we zoom into Ifs, Matches, and Blocks.
277257 */
@@ -342,6 +322,28 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
342322 case _ => false
343323 }
344324
325+ /** The largest subset of {NoInits, PureInterface} that a
326+ * trait or class enclosing this statement can have as flags.
327+ */
328+ def defKind (tree : Tree )(implicit ctx : Context ): FlagSet = unsplice(tree) match {
329+ case EmptyTree | _ : Import => NoInitsInterface
330+ case tree : TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
331+ case tree : DefDef =>
332+ if (tree.unforcedRhs == EmptyTree &&
333+ tree.vparamss.forall(_.forall(_.rhs.isEmpty))) NoInitsInterface
334+ else if (tree.mods.is(Given ) && tree.tparams.isEmpty && tree.vparamss.isEmpty)
335+ EmptyFlags // might become a lazy val: TODO: check whether we need to suppress NoInits once we have new lazy val impl
336+ else NoInits
337+ case tree : ValDef => if (tree.unforcedRhs == EmptyTree ) NoInitsInterface else EmptyFlags
338+ case _ => EmptyFlags
339+ }
340+
341+ /** The largest subset of {NoInits, PureInterface} that a
342+ * trait or class with this body can have as flags.
343+ */
344+ def bodyKind (body : List [Tree ])(implicit ctx : Context ): FlagSet =
345+ (NoInitsInterface /: body)((fs, stat) => fs & defKind(stat))
346+
345347 // todo: fill with other methods from TreeInfo that only apply to untpd.Tree's
346348}
347349
0 commit comments