scala – 禁止混合特定的特征
发布时间:2020-12-16 19:21:21 所属栏目:安全 来源:网络整理
导读:鉴于: trait Footrait Bar { this: Foo = }trait NoBar { this: Foo = } 有没有办法可以欺骗类型系统禁止: new Foo with Bar with NoBar {} 解决方法 并且类型擦除再次节省了一天: trait Footrait Dummy[A]trait Bar extends Dummy[Bar]{ this: Foo = }tr
鉴于:
trait Foo trait Bar { this: Foo => } trait NoBar { this: Foo => } 有没有办法可以欺骗类型系统禁止: new Foo with Bar with NoBar {} 解决方法
并且类型擦除再次节省了一天:
trait Foo trait Dummy[A] trait Bar extends Dummy[Bar]{ this: Foo => } trait NoBar extends Dummy[NoBar]{ this: Foo => } new Foo with Bar with NoBar {} 这会导致以下错误: illegal inheritance; anonymous class $anon inherits different type instances of trait Dummy: Dummy[Bar] and Dummy[NoBar] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |