Skip to content

Prefix not checked in realizability check for non-final lazy val #5521

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
abeln opened this issue Nov 26, 2018 · 0 comments
Closed

Prefix not checked in realizability check for non-final lazy val #5521

abeln opened this issue Nov 26, 2018 · 0 comments

Comments

@abeln
Copy link
Contributor

abeln commented Nov 26, 2018

  1 class Hello {
  2   class Foo {
  3     class Bar
  4     final lazy val s: Bar = ???
  5   }
  6 
  7   lazy val foo: Foo = ???
  8 
  9   val x: foo.s.type = ???
 10   val x2: foo.s.type = ???
 11 }

Expected: both line 9 and 10 produce an error.

Actual: only line 10 produces an error:

10 |  val x2: foo.s.type = ???
   |              ^
   |              Hello.this.foo.Bar(Hello.this.foo.s) is not a legal path
   |              since it refers to nonfinal lazy value foo

The reason is the cached and uncached cases are handled differently in https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala#L80
The uncached case doesn't check the prefix (hence why only the second time we try to use the same invalid path errors out).

@abeln abeln changed the title Prefix not checked in realizability check Prefix not checked in realizability check for non-final lazy val Nov 26, 2018
Blaisorblade added a commit that referenced this issue Dec 2, 2018
Fix #5521: prefix not checked in realizability check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant