Aladdin - Scala Bugtracking
[#142] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Philippe Martin fixed 2003-09-12 16:01:17.0
subject problems with mixins with nested types
code
import System.out.println;

abstract class Foo1 { class Inner; def foo: Inner; foo; }
abstract class Foo2 { class Inner; def foo: Inner = {println("ok"); null};      }
abstract class Foo3 { type  Inner; def foo: Inner; foo; }
abstract class Foo4 { type  Inner; def foo: Inner = {println("ok"); null.asInstanceOf[Inner]};      }

abstract class Bar1 { type  Inner; def foo: Inner = {println("ok"); null.asInstanceOf[Inner]};      }
abstract class Bar2 { type  Inner; def foo: Inner; foo; }
abstract class Bar3 { class Inner; def foo: Inner = {println("ok"); null};      }
abstract class Bar4 { class Inner; def foo: Inner; foo; }

object Test1 extends Foo1 with Bar1 {def main(args:Array[String]):Unit=();}
object Test2 extends Foo2 with Bar2 {def main(args:Array[String]):Unit=();}
object Test3 extends Foo3 with Bar3 {def main(args:Array[String]):Unit=();}
object Test4 extends Foo4 with Bar4 {def main(args:Array[String]):Unit=();}
object Test5 with    Foo1 with Bar1 {def main(args:Array[String]):Unit=();}
object Test6 with    Foo2 with Bar2 {def main(args:Array[String]):Unit=();}
object Test7 with    Foo3 with Bar3 {def main(args:Array[String]):Unit=();}
object Test8 with    Foo4 with Bar4 {def main(args:Array[String]):Unit=();}
what happened

Some programs raise an AbstractMethodError at runtime. One reason is that expand mixin does not rebind the t\ ype Inner in the inlined members and this prevents erasure to add some bridge methods. Another prob\ lem is that erasure should sometimes add a bridge method for methods that don't appear in the body of the class.\ That is for example the case when a concrete method is inherited from a superclass and an abstract one from a m\ ixin and the two methods have different erasures.

what expected

All programs should run without any error.

[back to overview]
Changes of this bug report
Philippe  edited on  2003-09-12 16:07:35.0
I assigned this bug to you Martin because I will be on holiday the next two weeks. If it's still there in two weeks, I will look with Michel how to solve it.
Philippe  edited on  2003-09-12 23:16:00.0

I patched ExpandMixin (added methods handleMixinInterfaceMembers) to replace (at least) some abstract types from mixins by concrete ones. This solved the problem for all tests except Test2 and Test4 .

I patched Erasure (added methods addInterfaceBridges) to add (at least) some of the bridge methods described above. This solved the problem for the last two failing tests.

Both patches need to be reviewed especially the one of Erasure.