测试中不可用的主要来源的类型别名

时间:2019-01-28 09:31:19

标签: scala sbt

编译测试源时,出现以下错误:

.../test/com/pckg/Spec.scala:2:18: Symbol 'type com.pckg.X' is missing from the classpath.
This symbol is required by 'value com.pckg.XUser.x'
Make sure that type X is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'XUser.class' was compiled against an incompatible version of com.pckg.package.

完全重建(clean)不能解决问题

别名和类的定义如下:

package com

package object pckg {
  type X = Int
}

XUser.scala:

package com.pckg

case class XUser(x: X)

Spec.scala:

package com.pckg

class Spec {
   val xuser = XUser(1)
}

这可能导致什么? Scala 2.12.8和sbt 1.2.8

1 个答案:

答案 0 :(得分:1)

问题是test/com/pckg/package.scala也存在,并定义了一个不同的包对象(带有用于测试代码的实用程序)。显然,这将覆盖主要的源包对象。