为什么Scala编译器在2.10中对自类型要求更严格?
我有以下代码:为什么Scala编译器在2.10中对自类型要求更严格?,scala,compiler-construction,types,self,type-systems,Scala,Compiler Construction,Types,Self,Type Systems,我有以下代码: trait TFn1B { type In type Out type Apply[T <: In] <: Out } trait TFn1[I, O] extends TFn1B { type In = I type Out = O } trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out]
trait TFn1B {
type In
type Out
type Apply[T <: In] <: Out
}
trait TFn1[I, O] extends TFn1B {
type In = I
type Out = O
}
trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
type Apply[T] = F2#Apply[F1#Apply[T]]
}
trait TFn1B{
输入
打字
类型Apply[T[F1[F1,F2]不符合此.TFn1[$1,$4]的自类型this.TFn1[$1,$4]
trait>[F1对我来说,它看起来像一个bug。对超类的类型参数没有限制,但更重要的是,-explaintypes
的跟踪对我来说是可疑的:
scala> trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
| type Apply[T] = F2#Apply[F1#Apply[T]]
| }
<console>:9: error: illegal inheritance;
self-type >>[F1,F2] does not conform to TFn1[_$1,_$4]'s selftype TFn1[_$1,_$4]
trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
^
>>[F1,F2] <: TFn1[_$1,_$4]?
TFn1[_$1,_$4] <: TFn1[_$1,_$4]?
_$1 <: _$1?
_$1 <: Nothing?
<notype> <: Nothing?
false
Any <: Nothing?
<notype> <: Nothing?
false
false
false
Any <: _$1?
Any <: Nothing?
<notype> <: Nothing?
false
false
false
false
false
false
scala>trait>[F1[F1,F2]不符合TFn1[$1,$4]的自类型TFn1[$1,$4]
trait>[F1[F1,F2]如Scala邮件列表(由您发布)所示:
它已打开(,)。
回归源于试图解决问题
潜在问题提交:
如果您留下类型应用
摘要会发生什么?鉴于2.10甚至还没有发布候选版本,在Scala邮件列表上讨论这一点是否更有意义?这有可能与“过于本地化的时间”警告相冲突。我对此进行了讨论。太lsow:-)。请参阅SI-5399,SI-5400。
scala> trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
| type Apply[T] = F2#Apply[F1#Apply[T]]
| }
<console>:9: error: illegal inheritance;
self-type >>[F1,F2] does not conform to TFn1[_$1,_$4]'s selftype TFn1[_$1,_$4]
trait >>[F1 <: TFn1[_, _], F2 <: TFn1[_, _]] extends TFn1[F1#In, F2#Out] {
^
>>[F1,F2] <: TFn1[_$1,_$4]?
TFn1[_$1,_$4] <: TFn1[_$1,_$4]?
_$1 <: _$1?
_$1 <: Nothing?
<notype> <: Nothing?
false
Any <: Nothing?
<notype> <: Nothing?
false
false
false
Any <: _$1?
Any <: Nothing?
<notype> <: Nothing?
false
false
false
false
false
false