summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-04-14 10:54:13 +0100
committerPaul Phillips <paulp@improving.org>2012-04-14 10:54:13 +0100
commit07f2e5fe7296d1c7e35fe53c1065a5c269b8d40c (patch)
tree647c44152467d2a1f3e349eb9359dfe9a80624a6 /src/compiler
parent625397b02ead976f7144d30868f1b058eb6823b6 (diff)
parent0ba3d542cc236ab2dbed3dc551920ede94787a0c (diff)
downloadscala-07f2e5fe7296d1c7e35fe53c1065a5c269b8d40c.tar.gz
scala-07f2e5fe7296d1c7e35fe53c1065a5c269b8d40c.tar.bz2
scala-07f2e5fe7296d1c7e35fe53c1065a5c269b8d40c.zip
Merge commit '625397b02e'; commit 'refs/pull/396/head' into develop
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index b4e0ad6edf..4fb9362ccc 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -166,7 +166,7 @@ trait Implicits {
}
def isCyclicOrErroneous =
- try containsError(tpe)
+ try sym.hasFlag(LOCKED) || containsError(tpe)
catch { case _: CyclicReference => true }
var useCountArg: Int = 0
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 988b821d1a..b7e0eaef2b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -184,8 +184,21 @@ trait Macros { self: Analyzer =>
def typedMacroBody(typer: Typer, ddef: DefDef): Tree = {
import typer.context
if (macroDebug) println("typechecking macro def %s at %s".format(ddef.symbol, ddef.pos))
+
typer.checkFeature(ddef.pos, MacrosFeature)
+ // [Eugene to Martin] todo. copy/pasted this from checkFeature, because don't know a better way
+ // this is necessary to prevent macros from typechecking/expanding when they are not enabled
+ // `checkFeature` call alone is not enough, because it merely posts validation callback to unit.toCheck
+ def hasImport = inferImplicit(EmptyTree: Tree, MacrosFeature.tpe, true, false, typer.context) != SearchFailure
+ val nestedOwners = MacrosFeature.owner.ownerChain.takeWhile(_ != languageFeatureModule.moduleClass).reverse
+ val featureName = (nestedOwners map (_.name + ".")).mkString + MacrosFeature.name
+ def hasOption = settings.language.value contains featureName
+ if (!hasImport && !hasOption) {
+ ddef.symbol setFlag IS_ERROR
+ return EmptyTree
+ }
+
implicit class AugmentedString(s: String) {
def abbreviateCoreAliases: String = { // hack!
var result = s