Skip to content

Visibility problem on self type reference. #4606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue May 18, 2011 · 2 comments
Closed

Visibility problem on self type reference. #4606

scabug opened this issue May 18, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented May 18, 2011

The following code compiles in 2.8.1 but not in 2.9.0.

class A(var x: Int)
class B(x: Int) extends A(x)
trait C { self: B => 
  def foo = x 
  def bar = self.x 
  def baz = {
    val b: B = self
    b.x
  }
}

object Toto extends App {
  val x = new B(10) with C
  println(x.foo) // 10
  println(x.bar) // 10
  println(x.baz) // 10
  println(x.x) // 10
}

=== Expected ===

No errors

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

test.scala:4: error: value x in class B cannot be accessed in C with B
  def foo = x 
            ^
test.scala:5: error: value x in class B cannot be accessed in C with B
  def bar = self.x 

=== Environment ===

  • Scala: 2.9.0.final
  • Java: java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
  • Operating system: OSX
@scabug
Copy link
Author

scabug commented May 18, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4606?orig=1
Reporter: thewolt

@scabug
Copy link
Author

scabug commented Jun 18, 2011

@paulp said:
#3194. (See the comments.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants