Skip to content

Conversation

@changvvb
Copy link
Contributor

@changvvb changvvb commented Jun 1, 2020

Fixes scala/bug#11870

(reverted in #9069)

@scala-jenkins scala-jenkins added this to the 2.13.4 milestone Jun 1, 2020
@SethTisue SethTisue modified the milestones: 2.13.4, 2.13.3 Jun 1, 2020
@changvvb
Copy link
Contributor Author

changvvb commented Jun 3, 2020

Jenkins pipeline is pending at https://scala-ci.typesafe.com/job/scala-2.13.x-validate-main/12079/console because error happened. Maybe it should be closed manually.

@SethTisue
Copy link
Member

@changvvb would you mind rebasing against the current head of 2.13.x? that should make the problem go away

@changvvb
Copy link
Contributor Author

changvvb commented Jun 4, 2020

@changvvb would you mind rebasing against the current head of 2.13.x? that should make the problem go away

@SethTisue It seems not work 😕.

@dwijnand dwijnand force-pushed the fix-annotation-SOE branch from 88d5b2a to 4c34306 Compare June 4, 2020 05:53
@dwijnand
Copy link
Member

dwijnand commented Jun 4, 2020

I'll re-fix the commits so we can reduce the noise merging this PR would bring.

@dwijnand dwijnand force-pushed the fix-annotation-SOE branch from 0c0eb8c to b8bb729 Compare June 4, 2020 09:52
@SethTisue SethTisue requested a review from retronym June 4, 2020 13:54
@changvvb changvvb force-pushed the fix-annotation-SOE branch from b288e5a to da80ac4 Compare June 5, 2020 12:41
@lrytz lrytz force-pushed the fix-annotation-SOE branch from da80ac4 to f88719d Compare June 5, 2020 12:49
Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @changvvb

@lrytz lrytz merged commit 0bfbfe7 into scala:2.13.x Jun 5, 2020
@changvvb changvvb deleted the fix-annotation-SOE branch June 13, 2020 09:42
@SethTisue
Copy link
Member

SethTisue commented Jun 17, 2020

@lrytz over at scala/community-build#1164 this caused a regression; one Akka source file started failing to compile. I isolated it to just:

import S._
@annotation.strictfp object S

error: encountered unrecoverable cycle resolving import.
Note: this is often due in part to a class depending on a definition nested within its companion.
If applicable, you may wish to try moving some members into another object.

(the exact annotation isn't important, e.g. @nowarn does the same thing)

such an import is a bit unusual. the Akka folks wanted it because they were doing this:

import S._
class C(x: Inner)
@internalApi object S { trait Inner}

and note that you can't move the import inside the class definition because the location where they want to refer to Inner is in a constructor parameter.

interestingly, Dotty has the same bug or limitation, whichever you want to call it:

scala> import S._ ; object S                                                                       
// defined object S

scala> import S._ ; @annotation.strictfp object S                                                                       
1 |import S._ ; @annotation.strictfp object S
  |              ^
  |              Cyclic reference involving module class S$

not sure if this is a 2.13.3-blocker or not. in the Akka source the problem is easy to work around because you can either 1) import S.Inner instead of import S._, or 2) skip the import entirely and just write out x: S.Inner

@SethTisue
Copy link
Member

@smarter would you like me to open a lampepfl/dotty ticket on this?

@retronym
Copy link
Member

I would suggest reverting this change for 2.13.3. Lazy typechecking of annotations can be relied on in pretty subtle ways.

Perhaps our annotation typechecking should have an extra phase:

  1. Lazy we know nothing about the annotation
  2. Typecheck the annotation qualifier, but not the arguments. This would be enough to answer Symbol#hasAnnotation / AnnotationInfo.matches, and would be transparently forced when calling these methods.
  3. Fully typechecked

If there are still cases that could run into a StackOverflowError in the uncheckedStable lookup, we could add cycle detection to turn this into a cyclic error report.

@lrytz
Copy link
Member

lrytz commented Jun 18, 2020

I like the suggestion of lazily type checking the parts of an AnnotationInfo and making the whole thing more transparent.

I also agree that reverting is the safer choice for 2.13.3.

@changvvb
Copy link
Contributor Author

Yes, Symbol#hasAnnotation can be more clever.

@SethTisue SethTisue removed this from the 2.13.3 milestone Jun 22, 2020
@SethTisue SethTisue changed the title Fix stackoverflow when referenced by self annotation REVERTED: Fix stackoverflow when referenced by self annotation Jun 22, 2020
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

Successfully merging this pull request may close these issues.

2.13.1 scalac StackOverflowError when annotation argument references the annottee

6 participants