aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-09 17:01:15 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-09 17:01:28 +0200
commite2639e08b097aa9e5cb1f9a38ef37c6caec05874 (patch)
treec7211ccb47be4fd4d945769d2cdad3ba909cb907 /compiler/src/dotty/tools/dotc/typer/Namer.scala
parentb8bb34dd0ea68cfed09ed54604f659a787037d2d (diff)
downloaddotty-e2639e08b097aa9e5cb1f9a38ef37c6caec05874.tar.gz
dotty-e2639e08b097aa9e5cb1f9a38ef37c6caec05874.tar.bz2
dotty-e2639e08b097aa9e5cb1f9a38ef37c6caec05874.zip
Fix #2198: Don't widen module singletons
Since module classes are a compiler-generated construct that's not directly visible to programmers, it seems better not to automatically widen a module singleton to its underlying class. Fixes #2198.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Namer.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala
index ce2030c01..b436b36b0 100644
--- a/compiler/src/dotty/tools/dotc/typer/Namer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala
@@ -1043,9 +1043,11 @@ class Namer { typer: Typer =>
def isInline = sym.is(FinalOrInline, butNot = Method | Mutable)
// Widen rhs type and approximate `|' but keep ConstantTypes if
- // definition is inline (i.e. final in Scala2).
+ // definition is inline (i.e. final in Scala2) and keep module singleton types
+ // instead of widening to the underlying module class types.
def widenRhs(tp: Type): Type = tp.widenTermRefExpr match {
- case tp: ConstantType if isInline => tp
+ case ctp: ConstantType if isInline => ctp
+ case ref: TypeRef if ref.symbol.is(ModuleClass) => tp
case _ => ctx.harmonizeUnion(tp.widen)
}