为什么 Def.inputTask 宏在 Scala 2.11.1 中不起作用? [英] Why doesn't the Def.inputTask macro work in Scala 2.11.1?

查看:19
本文介绍了为什么 Def.inputTask 宏在 Scala 2.11.1 中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Scala 2.11.1 和 sbt 0.13.5.

I'm using Scala 2.11.1 and sbt 0.13.5.

我有一个 sbt 插件,它包含一个辅助函数来创建输入任务,如下所示(实现被剥离,因为它与问题无关):

I have an sbt plugin that contains a helper function to create input tasks as follows (the implementation is stripped away as it's irrelevant to the problem):

def register(name: String, description: String): Def.Setting[InputTask[Unit]] = {
    InputKey[Unit](name, description) <<= Def.inputTask { 
        println("test")
    }
}

这个函数在 Scala 2.10.4 中编译和工作得很好,但是一旦我切换到 2.11.1,它就会失败并出现以下错误:

This function compiles and works just fine in Scala 2.10.4, however once I switch to 2.11.1 it fails with the following error:

无法扩展以前版本的 Scala 编译的宏

can't expand macros compiled by previous versions of Scala

Def.inputTask 宏是在 Scala 2.11.1 中简单损坏,还是我遗漏了一些明显的细节?

Is the Def.inputTask macro simply broken in Scala 2.11.1, or am I missing some glaring detail?

目前,上面的函数驻留在可以想象的最简单的 sbt 插件中.也完全没有依赖关系.

Right now the above function is residing in the simplest sbt plugin imaginable. There are no dependencies at all, either.

推荐答案

sbt 0.13.x 系列在加载时使用的是 Scala 2.10.x,所以 sbt 0.13.x 本身必须针对 Scala 2.10 编译,所有 sbt 也是如此0.13.x 的插件.

sbt 0.13.x series uses Scala 2.10.x when it loads up, so sbt 0.13.x itself must be compiled against Scala 2.10, and so do all sbt plugins for 0.13.x.

注意:sbt 0.13 可以使用 2.11.x 定义 Scala 项目.

Note: sbt 0.13 can define Scala projects using 2.11.x.

这篇关于为什么 Def.inputTask 宏在 Scala 2.11.1 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆