From c4561c1d4945a38febc41436ed333569d0e9a063 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 7 Apr 2014 10:41:31 +0200 Subject: SI-8479 Fix constructor default args under scaladoc The `DocDef` node hid the `DefDef` constructor from the scrutinee of the namer when determining if the class had constructor defaults or not. The current pattern for fixing these bugs is to delegate the check to `TreeInfo`, and account for the wrapper `DocDef` node. I've followed that pattern, but expressed my feelings about this approach in a TODO comment. Before this patch, the enclosed test failed with: error: not enough arguments for constructor SparkContext: (master: String, appName: String)SparkContext --- src/reflect/scala/reflect/internal/TreeInfo.scala | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/reflect') diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index fa4441e513..a6556fc22d 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -50,6 +50,11 @@ abstract class TreeInfo { case _ => false } + def isConstructorWithDefault(t: Tree) = t match { + case DefDef(_, nme.CONSTRUCTOR, _, vparamss, _, _) => mexists(vparamss)(_.mods.hasDefault) + case _ => false + } + /** Is tree a pure (i.e. non-side-effecting) definition? */ def isPureDef(tree: Tree): Boolean = tree match { -- cgit v1.2.3