From ee646e9c84290e721c4ee9fe6247d4b95840e871 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 5 Jun 2013 16:51:06 +0200 Subject: fixes a crash on a degenerate macro definition Previous version of the MacroImplReference extractor didn't take into the account the fact that RefTree.qualifier.symbol can be null (and it can be null if RefTree is an Ident, because then qualifier is an EmptyTree). This led to NPEs for really weird macro defs that refer to local methods as their corresponding macro impls. Now I check for this corner case, and the stuff now longer crashes. This was wrong; this is how I fixed it; the world is now a better place. --- src/reflect/scala/reflect/internal/TreeInfo.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/reflect') diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index d1e8a04553..3a8d3fd460 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -837,11 +837,12 @@ abstract class TreeInfo { def unapply(tree: Tree) = refPart(tree) match { case ref: RefTree => { - val isBundle = definitions.isMacroBundleType(ref.qualifier.tpe) + val qual = ref.qualifier + val isBundle = definitions.isMacroBundleType(qual.tpe) val owner = - if (isBundle) ref.qualifier.tpe.typeSymbol + if (isBundle) qual.tpe.typeSymbol else { - val sym = ref.qualifier.symbol + val sym = if (qual.hasSymbolField) qual.symbol else NoSymbol if (sym.isModule) sym.moduleClass else sym } Some((isBundle, owner, ref.symbol, dissectApplied(tree).targs)) -- cgit v1.2.3