summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-02-23 10:01:24 -0600
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-23 10:01:24 -0600
commitefa99c01974febe227937f090afbb93b9a6a59a5 (patch)
treea5656dda5c063d10c9d72f614a39ceb8a7828b1c /src
parent6a9767b95216badc5cc8080f430d6a517fbdac4a (diff)
parentdded01b234542501fa62821376a4d853e24250d4 (diff)
downloadscala-efa99c01974febe227937f090afbb93b9a6a59a5.tar.gz
scala-efa99c01974febe227937f090afbb93b9a6a59a5.tar.bz2
scala-efa99c01974febe227937f090afbb93b9a6a59a5.zip
Merge pull request #3571 from xeno-by/ticket/8321
SI-8321 bundles can't be whitebox
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Errors.scala2
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Resolvers.scala17
-rw-r--r--src/compiler/scala/reflect/macros/compiler/Validators.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala13
4 files changed, 14 insertions, 20 deletions
diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala
index 490ab3657a..cc4508e696 100644
--- a/src/compiler/scala/reflect/macros/compiler/Errors.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala
@@ -36,7 +36,7 @@ trait Errors extends Traces {
def MacroBundleNonStaticError() = bundleRefError("macro bundles must be static")
- def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter")
+ def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete monomorphic classes having a single constructor with a `val c: Context` parameter")
trait Error {
self: MacroImplRefCompiler =>
diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
index 807fb688a0..4484c234aa 100644
--- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala
@@ -25,22 +25,11 @@ trait Resolvers {
typer.silent(_.typed(markMacroImplRef(core)), reportAmbiguousErrors = false).nonEmpty
}
- lazy val macroImplRef: Tree =
+ lazy val (macroImplRef, isBlackbox, macroImplOwner, macroImpl, targs) =
typer.silent(_.typed(markMacroImplRef(untypedMacroImplRef)), reportAmbiguousErrors = false) match {
- case SilentResultValue(success) => success
+ case SilentResultValue(macroImplRef @ MacroImplReference(_, isBlackbox, owner, meth, targs)) => (macroImplRef, isBlackbox, owner, meth, targs)
+ case SilentResultValue(macroImplRef) => MacroImplReferenceWrongShapeError()
case SilentTypeError(err) => abort(err.errPos, err.errMsg)
}
-
- // FIXME: cannot write this concisely because of SI-7507
- // lazy val (_, macroImplOwner, macroImpl, macroImplTargs) =
- private lazy val dissectedMacroImplRef =
- macroImplRef match {
- case MacroImplReference(isBundle, isBlackbox, owner, meth, targs) => (isBlackbox, owner, meth, targs)
- case _ => MacroImplReferenceWrongShapeError()
- }
- lazy val isImplBlackbox = dissectedMacroImplRef._1
- lazy val macroImplOwner = dissectedMacroImplRef._2
- lazy val macroImpl = dissectedMacroImplRef._3
- lazy val targs = dissectedMacroImplRef._4
}
}
diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala
index fc118028dd..a146818ae3 100644
--- a/src/compiler/scala/reflect/macros/compiler/Validators.scala
+++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala
@@ -147,7 +147,7 @@ trait Validators {
// had to move method's body to an object because of the recursive dependencies between sigma and param
object SigGenerator {
val cache = scala.collection.mutable.Map[Symbol, Symbol]()
- val ctxTpe = if (isImplBlackbox) BlackboxContextClass.tpe else WhiteboxContextClass.tpe
+ val ctxTpe = if (isBlackbox) BlackboxContextClass.tpe else WhiteboxContextClass.tpe
val ctxPrefix =
if (isImplMethod) singleType(NoPrefix, makeParam(nme.macroContext, macroDdef.pos, ctxTpe, SYNTHETIC))
else singleType(ThisType(macroImpl.owner), macroImpl.owner.tpe.member(nme.c))
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index e1d760a87a..558e1aa611 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -622,14 +622,19 @@ trait Definitions extends api.StandardDefinitions {
macroBundleParamInfo(tp) != NoType
def isMacroBundleType(tp: Type) = {
- val isContextCompatible = macroBundleParamInfo(tp) != NoType
+ val isMonomorphic = tp.typeSymbol.typeParams.isEmpty
+ val isContextCompatible = isMacroContextType(macroBundleParamInfo(tp))
val hasSingleConstructor = !tp.declaration(nme.CONSTRUCTOR).isOverloaded
val nonAbstract = !tp.erasure.typeSymbol.isAbstractClass
- isContextCompatible && hasSingleConstructor && nonAbstract
+ isMonomorphic && isContextCompatible && hasSingleConstructor && nonAbstract
}
- def isBlackboxMacroBundleType(tp: Type) =
- isMacroBundleType(tp) && (macroBundleParamInfo(tp) <:< BlackboxContextClass.tpe)
+ def isBlackboxMacroBundleType(tp: Type) = {
+ val isBundle = isMacroBundleType(tp)
+ val unwrappedContext = MacroContextType.unapply(macroBundleParamInfo(tp)).getOrElse(NoType)
+ val isBlackbox = unwrappedContext =:= BlackboxContextClass.tpe
+ isBundle && isBlackbox
+ }
def isListType(tp: Type) = tp <:< classExistentialType(ListClass)
def isIterableType(tp: Type) = tp <:< classExistentialType(IterableClass)