From 23826f56eb08406ef464ff0a8058a79768f89bee Mon Sep 17 00:00:00 2001 From: Ruslan Shevchenko Date: Sat, 13 Feb 2021 08:33:28 +0200 Subject: [PATCH] fix #11331 (also split the test from #11335) --- .../dotty/tools/dotc/core/SymDenotations.scala | 5 ++++- .../dotc/BootstrappedOnlyCompilationTests.scala | 1 + tests/pos-special/i11331.1/Macro_1.scala | 16 ++++++++++++++++ tests/pos-special/i11331.1/Test_2.scala | 10 ++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/pos-special/i11331.1/Macro_1.scala create mode 100644 tests/pos-special/i11331.1/Test_2.scala diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 4b04d8b8c108..8786073d80a4 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -2207,7 +2207,9 @@ object SymDenotations { if !myCompanion.exists then ensureCompleted() myCompanion - override def registeredCompanion_=(c: Symbol) = { myCompanion = c } + + override def registeredCompanion_=(c: Symbol) = + myCompanion = c private var myNestingLevel = -1 @@ -2458,6 +2460,7 @@ object SymDenotations { || owner.isRefinementClass || owner.is(Scala2x) || owner.unforcedDecls.contains(denot.name, denot.symbol) + || (denot.is(Synthetic) && denot.is(ModuleClass) && stillValidInOwner(denot.companionClass)) || denot.isSelfSym || denot.isLocalDummy) catch case ex: StaleSymbol => false diff --git a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala index b009533cf8d5..d0e1a2c1540c 100644 --- a/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala @@ -28,6 +28,7 @@ class BootstrappedOnlyCompilationTests { compileFilesInDir("tests/pos-macros", defaultOptions), compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")), compileDir("tests/pos-special/i7592", defaultOptions.and("-Yretain-trees")), + compileDir("tests/pos-special/i11331.1", defaultOptions), ).checkCompile() } diff --git a/tests/pos-special/i11331.1/Macro_1.scala b/tests/pos-special/i11331.1/Macro_1.scala new file mode 100644 index 000000000000..f02d02d63d5b --- /dev/null +++ b/tests/pos-special/i11331.1/Macro_1.scala @@ -0,0 +1,16 @@ +package i11331 + +import scala.quoted._ + +class I11331Class + + +object X: + + inline def process[T](inline f:T) = ${ + processImpl[T]('f) + } + + def processImpl[T:Type](t:Expr[T])(using Quotes):Expr[T] = + import quotes.reflect._ + t diff --git a/tests/pos-special/i11331.1/Test_2.scala b/tests/pos-special/i11331.1/Test_2.scala new file mode 100644 index 000000000000..b4ec444d93a4 --- /dev/null +++ b/tests/pos-special/i11331.1/Test_2.scala @@ -0,0 +1,10 @@ +package i11331 + + +object Main: + + def main(args:Array[String]):Unit = + X.process{ + val a = new I11331Class + a + }