aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala7
-rw-r--r--tests/pos/i324.scala7
2 files changed, 13 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 42ee513cd..ac46ee723 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -8,6 +8,7 @@ import Scopes._, Contexts._, Constants._, Types._, Symbols._, Names._, Flags._,
import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._, TypeErasure._
import util.Positions._
import config.Printers._
+import NameOps._
trait TypeAssigner {
import tpd._
@@ -16,7 +17,11 @@ trait TypeAssigner {
* @param packageOk The qualifier may refer to a package.
*/
def qualifyingClass(tree: untpd.Tree, qual: Name, packageOK: Boolean)(implicit ctx: Context): Symbol = {
- def qualifies(sym: Symbol) = sym.isClass && (qual.isEmpty || sym.name == qual)
+ def qualifies(sym: Symbol) =
+ sym.isClass && (
+ qual.isEmpty ||
+ sym.name == qual ||
+ sym.is(Module) && sym.name.stripModuleClassSuffix == qual)
ctx.outersIterator.map(_.owner).find(qualifies) match {
case Some(c) if packageOK || !(c is Package) =>
c
diff --git a/tests/pos/i324.scala b/tests/pos/i324.scala
new file mode 100644
index 000000000..5461379be
--- /dev/null
+++ b/tests/pos/i324.scala
@@ -0,0 +1,7 @@
+class O
+object O {
+ val x: this.type = O.this
+}
+object O2 {
+ val x: this.type = O2.this
+}