Skip to content

Conversation

@milessabin
Copy link
Contributor

outerSelect returns EmptyTree if it hits a Symbol with no outer accessor. outerPath doesn't check for this and will happily hand the returned EmptyTree back to outerSelect, and so on until stack overflow.
The fix is to check for an EmptyTree result and terminate.

Fixes scala/bug#10035.

else {
val outerSel = outerSelect(base)
if(outerSel == EmptyTree) EmptyTree
else outerPath(outerSelect(base), from.outerClass, to)
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably intended to use outerSel again. Also, space after if! Ahh! if is not a function call!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh good grief ... inexcusable.

@som-snytt
Copy link
Contributor

The PR title is very Zen.

Copy link
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

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

Hey, it works! One style nit. I hesitate to call it that, because Miles is a style icon. I guess in the sense of lifestyle icon.

else outerPath(outerSelect(base), from.outerClass, to)
else {
val outerSel = outerSelect(base)
if (outerSel == EmptyTree) EmptyTree
Copy link
Contributor

Choose a reason for hiding this comment

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

if (outerSel.isEmpty) is idiomatic, it turns out.

outerSelect returns EmptyTree if it hits a Symbol with no outer
accessor. outerPath doesn't check for this and will happily hand the
returned EmptyTree back to outerSelect, and so on until stack overflow.
The fix is to check for an EmptyTree result and terminate.

Fixes scala#10035.
@milessabin
Copy link
Contributor Author

Used isEmpty and squashed.

@lrytz lrytz merged commit 58c50d9 into scala:2.13.x Oct 1, 2018
ivanopagano added a commit to ivanopagano/scala that referenced this pull request Jul 16, 2020
 * copy the bugfix for scala/bug#10035 to the 2.12.x branch, as-is
ivanopagano added a commit to ivanopagano/scala that referenced this pull request Jul 17, 2020
 * copy the bugfix for scala/bug#10035 to the 2.12.x branch, as-is
ivanopagano added a commit to ivanopagano/scala that referenced this pull request Jul 17, 2020
 * copy the bugfix for scala/bug#10035 to the 2.12.x branch, as-is
dwijnand added a commit to dwijnand/scala that referenced this pull request Sep 14, 2020
* commit 'e32b224ee1':
  Emit method reference lambdas without helper method
  Add same changes from the PR scala#7178
  [backport] Exchange stack for Stack in assertNotReachable
  [backport] Avoid race in test for firstCompletedOf
  Remove exploratory assertions
  Stabilize order of synthetic modules in enclosing class decls
  Bump to Scala 2.12.12
  [backport] bring AssertUtil fixes to 2.12
  Add a comment to HashMap.castToThat
  [nomerge] small cleanups
  [backport] Disable all reusable instances in runtime reflection
  [backport] Rework recent, buggy change to immutable.TreeMap
hamzaremmal pushed a commit to hamzaremmal/scala3 that referenced this pull request May 2, 2025
* commit 'e32b224ee1':
  Emit method reference lambdas without helper method
  Add same changes from the PR scala/scala#7178
  [backport] Exchange stack for Stack in assertNotReachable
  [backport] Avoid race in test for firstCompletedOf
  Remove exploratory assertions
  Stabilize order of synthetic modules in enclosing class decls
  Bump to Scala 2.12.12
  [backport] bring AssertUtil fixes to 2.12
  Add a comment to HashMap.castToThat
  [nomerge] small cleanups
  [backport] Disable all reusable instances in runtime reflection
  [backport] Rework recent, buggy change to immutable.TreeMap
hamzaremmal pushed a commit to scala/scala3 that referenced this pull request May 7, 2025
* commit 'e32b224ee1':
  Emit method reference lambdas without helper method
  Add same changes from the PR scala/scala#7178
  [backport] Exchange stack for Stack in assertNotReachable
  [backport] Avoid race in test for firstCompletedOf
  Remove exploratory assertions
  Stabilize order of synthetic modules in enclosing class decls
  Bump to Scala 2.12.12
  [backport] bring AssertUtil fixes to 2.12
  Add a comment to HashMap.castToThat
  [nomerge] small cleanups
  [backport] Disable all reusable instances in runtime reflection
  [backport] Rework recent, buggy change to immutable.TreeMap
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.

Compiler crash when accessing member inside auxiliary constructor

3 participants