Skip to content

super[T] not working inside an anonymous function (e.g. for loop) #4300

Closed
@scabug

Description

@scabug

=== What steps will reproduce the problem? ===

trait A {
	def f() = println("A")
}

class B extends A {
	def g() = for(i <- 0 until 1) super[A].f()
	def h() = for(i <- 0 until 1) B.super[A].f()
}

val b = new B()
b.g() // ClassCastException
b.h() // ClassCastException

=== What is the expected behavior? ===

The expected output is

A
A

=== What do you see instead? ===

ClassCastException is thrown, as the compiler tries to cast the anonymous function to A.

=== Additional information ===
http://groups.google.com/group/scala-user/browse_thread/thread/757e3c5efb85c607

=== What versions of the following are you using? ===

  • Scala: 2.8.1
  • Java: 1.6.0_20
  • Operating system: Ubuntu Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions