Aladdin - Scala Bugtracking
[#1236] project: compiler priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-07-23 10:48:51.0
subject [contrib #711] AbstractMethodError with
code
// tested with nightly build  scala-2.5.1.12368.20070720-074545


object AbstractMethodErrorTest extends Application
{
    def flattenWithSelf[T](self: T, deps: => List[T], recurse: T => List[T]): List[T] =
    {
        self :: deps.flatMap(recurse(_)).removeDuplicates
    }

    abstract class Module
    { self =>
        final type commonModuleType = Module
    
        protected def moduleDemands: List[Module]
    
        final def moduleRequirementsWithSelf: List[commonModuleType] =
            flattenWithSelf[Module](self, moduleDemands, _.moduleRequirementsWithSelf)
    }

    object FirstModule extends Module
    {
        def moduleDemands: List[Module] = Nil
    }

    object SecondModule extends Module
    {
        def moduleDemands: List[Module] = List(FirstModule)
    }

    assert(SecondModule.moduleRequirementsWithSelf == List(SecondModule, FirstModule))
}


/*
Exception in thread "main" java.lang.AbstractMethodError: AbstractMethodErrorTest$Module$$anonfun$2.apply(Ljava/lang/Object;)Ljava/lang/Object;
	at AbstractMethodErrorTest$$anonfun$0.apply(AbstractMethodErrorTest.scala:8)
	at AbstractMethodErrorTest$$anonfun$0.apply(AbstractMethodErrorTest.scala:8)
	at scala.List.flatMap(List.scala:995)
	at AbstractMethodErrorTest$.flattenWithSelf(AbstractMethodErrorTest.scala:8)
	at AbstractMethodErrorTest$Module.moduleRequirementsWithSelf(AbstractMethodErrorTest.scala:18)
	at AbstractMethodErrorTest$.<init>(AbstractMethodErrorTest.scala:31)
	at AbstractMethodErrorTest$.<clinit>(AbstractMethodErrorTest.scala)
	at AbstractMethodErrorTest.main(AbstractMethodErrorTest.scala)


Note that changing a return type gives successful execution:
// final def moduleRequirementsWithSelf: List[Module]

*/
what happened
java.lang.AbstractMethodError at runtime
what expected successful execution with no output, as occurs with 2.5.1-final
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-07-23 10:51:43.0
Iulian  edited on  2007-07-23 18:26:42.0
The closure class for (_.moduleRequirementsWithSelf) is missing a bridge method for its apply. Routed to Martin.
Martin  edited on  2007-07-25 23:18:48.0