From ca1dbcc3c0cfc8bf681777b678d5c037512ad696 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 6 Jan 2021 17:07:27 +0100 Subject: [PATCH] Avoid stackoverflow in associatedFile computation --- compiler/src/dotty/tools/dotc/core/Symbols.scala | 2 +- tests/neg/i9327.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i9327.scala diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 855f88690be8..d8e107852947 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -429,7 +429,7 @@ object Symbols { /** The source or class file from which this class was generated, null if not applicable. */ override def associatedFile(using Context): AbstractFile = - if (assocFile != null || this.owner.is(PackageClass) || this.isEffectiveRoot) assocFile + if assocFile != null || this.is(Package) || this.owner.is(Package) then assocFile else super.associatedFile private var mySource: SourceFile = NoSource diff --git a/tests/neg/i9327.scala b/tests/neg/i9327.scala new file mode 100644 index 000000000000..3b0cf1824f82 --- /dev/null +++ b/tests/neg/i9327.scala @@ -0,0 +1,4 @@ +// fuzzball, gave SO in associatedFile +package object Foo // error +type Foo // error +class Foo(a: Foo) \ No newline at end of file