Skip to content
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

scope escape checking for qualified private #4323

Closed
scabug opened this issue Mar 8, 2011 · 4 comments
Closed

scope escape checking for qualified private #4323

scabug opened this issue Mar 8, 2011 · 4 comments
Labels

Comments

@scabug
Copy link

scabug commented Mar 8, 2011

I can't figure out for sure from code or spec what is supposed to happen here, but I feel there must be a bug when "object X" is used as the accessible fallback to "X.type".

package privates {
  object A { 
    val b = B
    val c = C
  }
  
  // givn this way it correctly fails
  // private object B
  //
  // privates.scala:4: error: private object B escapes its defining scope as part of type object privates.B
  //     val b = B
  //         ^
  // one error found
   
  // Should this type be inferred for a public val in A?
  // I would think not.  But then the fallback should be AnyRef, or ScalaObject.
  private[privates] object B
  object C
}

package other {
  object C {
    val b = privates.A.b
    val c = privates.A.c
  }
}

This compiles, and look at the types of b and c as inferred in other.C.

// Decides privates.B.type is off limits, so infers "object B"
scala> other.C.b _
res0: () => object privates.B = <function0>

// Doesn't mind inferring privates.C.type
scala> other.C.c _
res1: () => privates.C.type = <function0>
@scabug
Copy link
Author

scabug commented Mar 8, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4323?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Mar 8, 2011

@ingoem said:
This one goes to meeting for your personal entertainment.

@SethTisue
Copy link
Member

I can't figure out for sure from code or spec what is supposed to happen here

someone can comment and/or reopen if they have an opinion on this

@som-snytt
Copy link

Use case

package p {
  object A {
    val b = B
    val c = C
  }

  private[p] object B
  object C

  class D {
    def f(x: B.type) = x
  }
}

package other {
  object C {
    val b = p.A.b
    val c = p.A.c
    def f = new p.D().d.f(b)
  }
}

@SethTisue SethTisue removed this from the Backlog milestone Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants