From 2df52b954143e74f382276d9f9cca3102b4ceb29 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 18 Apr 2022 13:15:34 +0200 Subject: [PATCH] Fix outer reference detection in class parents The case where a class parent was an AppliedType was missing. Hence, classes that referred to an outer this only via a parent were mis-categorized. --- .../src/dotty/tools/dotc/transform/ExplicitOuter.scala | 3 ++- tests/pos/i14932.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i14932.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index a7f8421f51d0..0a9798226d76 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -278,7 +278,8 @@ object ExplicitOuter { ) case _ => false } - def hasOuterPrefix(tp: Type) = tp match { + def hasOuterPrefix(tp: Type): Boolean = tp.stripped match { + case AppliedType(tycon, _) => hasOuterPrefix(tycon) case TypeRef(prefix, _) => isOuterRef(prefix) case _ => false } diff --git a/tests/pos/i14932.scala b/tests/pos/i14932.scala new file mode 100644 index 000000000000..8fff627fc3d7 --- /dev/null +++ b/tests/pos/i14932.scala @@ -0,0 +1,9 @@ +trait Core { + class Base[T]() +} + +class Module(val core: Core) { + object Indirection { + class Extension[T]() extends core.Base[T]() + } +} \ No newline at end of file