From 5a40641cc158e370026df263fcdd124f09c6c574 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Sun, 16 Mar 2014 17:09:02 +0100 Subject: [PATCH] Classes that only inherit a macro don't have a macro Prior to this commit, a class that inherited a macro from another class was considered by incremental compiler as having a macro. Now, only classes that explicitly define a macro are considered as having a macro. This influences decision whether to invalidate (recompile) dependencies of a file that inherits a macro upon a whitespace change. From now on, we don't invalidate dependencies in such case which results in much better incremental compiler experience when macros are being involved. Check #1142 for detailed discussion. The change to the behavior is reflected by marking the source-dependencies/inherited-macros test as passing. The source-dependencies/macro test covers the case of defining the macro directly in source file. Therefore we know that the desired behavior of invalidating dependencies of macros is preserved. Fixes #1142 --- compile/api/src/main/scala/xsbt/api/APIUtil.scala | 8 ++++++++ .../inherited-macros/{pending => test} | 0 2 files changed, 8 insertions(+) rename sbt/src/sbt-test/source-dependencies/inherited-macros/{pending => test} (100%) diff --git a/compile/api/src/main/scala/xsbt/api/APIUtil.scala b/compile/api/src/main/scala/xsbt/api/APIUtil.scala index 96892f3d8..50d287fe4 100644 --- a/compile/api/src/main/scala/xsbt/api/APIUtil.scala +++ b/compile/api/src/main/scala/xsbt/api/APIUtil.scala @@ -29,6 +29,14 @@ object APIUtil { var hasMacro = false + // Don't visit inherited definitions since we consider that a class + // that inherits a macro does not have a macro. + override def visitStructure0(structure: Structure) + { + visitTypes(structure.parents) + visitDefinitions(structure.declared) + } + override def visitModifiers(m: Modifiers) { hasMacro ||= m.isMacro diff --git a/sbt/src/sbt-test/source-dependencies/inherited-macros/pending b/sbt/src/sbt-test/source-dependencies/inherited-macros/test similarity index 100% rename from sbt/src/sbt-test/source-dependencies/inherited-macros/pending rename to sbt/src/sbt-test/source-dependencies/inherited-macros/test