diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-21 22:24:21 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-21 22:24:32 +0100 |
commit | 64edb44fc6a4db0ba3ecee0555212d8112a17f1a (patch) | |
tree | 908712ca8bb1a03820fa0b6e1a407e6f34fc7bc3 /src | |
parent | da1032caa4ee4c780b5fff3056dd816623a53737 (diff) | |
download | scala-64edb44fc6a4db0ba3ecee0555212d8112a17f1a.tar.gz scala-64edb44fc6a4db0ba3ecee0555212d8112a17f1a.tar.bz2 scala-64edb44fc6a4db0ba3ecee0555212d8112a17f1a.zip |
more helpful bundle error messages
At the moment, bundle selection mechanism is pretty picky. If a candidate
bundle's parameter isn't either blackbox.Context, whitebox.Context or
PrefixType refinement thereof, then it's not a bundle and the user
will get a generic error.
However we can be a bit more helpful and admit classes that are almost
like bundles (looksLikeMacroBundleType), have them fail isMacroBundleType,
and then emit a much prettier error message to the user that would tell them
that bundles must be monomorphic and their sole parameter should not just
be any subtype of blackbox.Context or whitebox.Context.
Diffstat (limited to 'src')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 62e98829b7..558e1aa611 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -609,8 +609,12 @@ trait Definitions extends api.StandardDefinitions { private def macroBundleParamInfo(tp: Type) = { val ctor = tp.erasure.typeSymbol.primaryConstructor ctor.paramss match { - case List(List(c)) => if (isMacroContextType(c.info)) c.info else NoType - case _ => NoType + case List(List(c)) => + val sym = c.info.typeSymbol + val isContextCompatible = sym.isNonBottomSubClass(BlackboxContextClass) || sym.isNonBottomSubClass(WhiteboxContextClass) + if (isContextCompatible) c.info else NoType + case _ => + NoType } } @@ -619,7 +623,7 @@ trait Definitions extends api.StandardDefinitions { def isMacroBundleType(tp: Type) = { val isMonomorphic = tp.typeSymbol.typeParams.isEmpty - val isContextCompatible = macroBundleParamInfo(tp) != NoType + val isContextCompatible = isMacroContextType(macroBundleParamInfo(tp)) val hasSingleConstructor = !tp.declaration(nme.CONSTRUCTOR).isOverloaded val nonAbstract = !tp.erasure.typeSymbol.isAbstractClass isMonomorphic && isContextCompatible && hasSingleConstructor && nonAbstract |