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

查看:80
本文介绍了为什么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天全站免登陆