Skip to content

Fix #6460: less forcing in checkNonCyclic #6493

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

Merged
merged 2 commits into from
May 11, 2019

Conversation

smarter
Copy link
Member

@smarter smarter commented May 10, 2019

checkNonCyclic was forcing too many infos because it didn't account for
the case where the prefix is a ModuleVal and not a ModuleClass. Fixing
this solves the incremental compilation issue in the Dotty build
reported in #6460 were the root cause was a completion cycle when
jointly compiling SymbolLoaders and Types that looked like this:

Complete object tpd
Complete its parent Trees.Instance
Complete its type parameter T >: Untyped <: Type
run checkNonCyclic on the the type parameter definition
Complete Type
Complete import ast.tpd._ in Types.scala
Eventually this requires unpickling the selection Trees.Instance#T which
gets a NoDenotation since T hasn't been entered yet.

As a side-effect this also means that the neg/toplevel-cyclic
test no longer leads to an "illegal cyclic reference" error, instead it
now causes "recursion limit exceeded" errors, which are less nice but
still acceptable.

@smarter smarter requested a review from odersky May 10, 2019 20:40
@smarter smarter force-pushed the fix-checkNonCyclic branch 2 times, most recently from 41f5bbd to 07ed256 Compare May 10, 2019 22:16
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

👍 Great detective work!

@smarter smarter force-pushed the fix-checkNonCyclic branch from 07ed256 to d406860 Compare May 11, 2019 13:06
final def moduleClass(implicit ctx: Context): Symbol = {
def notFound = {
if (Config.showCompletions) println(s"missing module class for $name: $myInfo")
NoSymbol
}
if (this is ModuleVal)
if (this is ModuleClass)
Copy link
Contributor

Choose a reason for hiding this comment

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

For speed I'd move the operations that return the same symbol towards the end, i.e. where otherwise NoSymbol would be returned.

* otherwise NoSymbol
*/
final def sourceModule(implicit ctx: Context): Symbol =
if (this is ModuleVal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@smarter smarter force-pushed the fix-checkNonCyclic branch 2 times, most recently from 3357727 to d86fcb6 Compare May 11, 2019 13:50
@smarter smarter force-pushed the fix-checkNonCyclic branch from d86fcb6 to 1cbec0b Compare May 11, 2019 14:46
smarter added 2 commits May 11, 2019 18:18
This is more intuitive in my opinion.

As a side-effect, this makes the logic for creating stub package symbols
in `staticRef` more robust which broke the `missingDottyLib` test. This
is fixed by moving the `isPackageFromCoreLibMissing` check earlier.
checkNonCyclic was forcing too many infos because it didn't account for
the case where the prefix is a ModuleVal and not a ModuleClass. Fixing
this solves the incremental compilation issue in the Dotty build
reported in scala#6460 were the root cause was a completion cycle when
jointly compiling SymbolLoaders and Types that looked like this:

Complete `object tpd`
 Complete its parent `Trees.Instance`
  Complete its type parameter `T >: Untyped <: Type`
    run `checkNonCyclic` on the the type parameter definition
      Complete `Type`
        Complete `import ast.tpd._` in `Types.scala`
          Eventually this requires unpickling the selection `Trees.Instance#T` which
          gets a `NoDenotation` since `T` hasn't been entered yet.

As a side-effect this also means that the neg/toplevel-cyclic
test no longer leads to an "illegal cyclic reference" error, instead it
now causes "recursion limit exceeded" errors, which are less nice but
still acceptable.
@smarter smarter force-pushed the fix-checkNonCyclic branch from 1cbec0b to a11de49 Compare May 11, 2019 16:26
@smarter smarter merged commit d79eb0e into scala:master May 11, 2019
@allanrenucci allanrenucci deleted the fix-checkNonCyclic branch May 11, 2019 19:43
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 participants