diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-21 21:48:16 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-21 21:56:09 +0100 |
commit | 31b52ed651e58a68d478aabe41c62287b6d4d718 (patch) | |
tree | 15d3d74c2a7b1b76de62f9e5b8abd4225718551c /src/reflect | |
parent | 42031708b25f7252fab9992fe444651f8c141e40 (diff) | |
download | scala-31b52ed651e58a68d478aabe41c62287b6d4d718.tar.gz scala-31b52ed651e58a68d478aabe41c62287b6d4d718.tar.bz2 scala-31b52ed651e58a68d478aabe41c62287b6d4d718.zip |
bundles now reject invalid context types
Vanilla macros only allow blackbox.Context, whitebox.Context and
PrefixType refinements thereof. Bundles should behave in the same way.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 20f6d51fcf..f8f7673530 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -609,12 +609,8 @@ trait Definitions extends api.StandardDefinitions { private def macroBundleParamInfo(tp: Type) = { val ctor = tp.erasure.typeSymbol.primaryConstructor ctor.paramss match { - 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 + case List(List(c)) => if (isMacroContextType(c.info)) c.info else NoType + case _ => NoType } } @@ -630,9 +626,9 @@ trait Definitions extends api.StandardDefinitions { def isBlackboxMacroBundleType(tp: Type) = { val isBundle = isMacroBundleType(tp) - val isBlackbox = (macroBundleParamInfo(tp) <:< BlackboxContextClass.tpe) - val notWhitebox = !(macroBundleParamInfo(tp) <:< WhiteboxContextClass.tpe) - isBundle && isBlackbox && notWhitebox + val unwrappedContext = MacroContextType.unapply(macroBundleParamInfo(tp)).getOrElse(NoType) + val isBlackbox = unwrappedContext =:= BlackboxContextClass.tpe + isBundle && isBlackbox } def isListType(tp: Type) = tp <:< classExistentialType(ListClass) |