Skip to content

annotation.targetName makes trait "lazy val" a "def" #13358

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
edolgy opened this issue Aug 23, 2021 · 1 comment · Fixed by #13592
Closed

annotation.targetName makes trait "lazy val" a "def" #13358

edolgy opened this issue Aug 23, 2021 · 1 comment · Fixed by #13592
Assignees

Comments

@edolgy
Copy link

edolgy commented Aug 23, 2021

Compiler version

3.0.2-RC1

Minimized code

object Test:
  var cnt = 0

  trait Foo:
    lazy val foo1 = {cnt+=1; cnt}
    
    @scala.annotation.targetName("fooTwo") 
    lazy val foo2 = {cnt+=1; cnt}

  object Bar extends Foo

  def main(sa: Array[String]): Unit =

    println(Bar.foo1)  // Prints 1
    println(Bar.foo1)  // Prints 1
    println(Bar.foo1)  // Prints 1
    println(Bar.foo1)  // Prints 1

    println(Bar.foo2)  // Prints 2  
    println(Bar.foo2)  // Prints 3  EXPECTED 2
    println(Bar.foo2)  // Prints 4  EXPECTED 2
    println(Bar.foo2)  // Prints 5  EXPECTED 2

This issue might be related to 13252

@odersky odersky self-assigned this Aug 23, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue Sep 23, 2021
@odersky
Copy link
Contributor

odersky commented Sep 23, 2021

Looks like this is fixed in master

bishabosha added a commit that referenced this issue Sep 23, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants