Skip to content

Fix #1447: Make X$ <:< X.type when X is an object #1448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
// However the original judgment should be true.
case _ =>
}
val sym1 = tp1.symbol
val sym1 =
if (tp1.symbol.is(ModuleClass) && tp2.symbol.is(ModuleVal))
// For convenience we want X$ <:< X.type
// This is safe because X$ self-type is X.type
tp1.symbol.companionModule
else
tp1.symbol
if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol))
ctx.erasedTypes ||
sym1.isStaticOwner ||
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i1447.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
case object X

object Test {
val Alias = X

val x: X.type = Alias

type Alias = X.type
val a: Alias = Alias
}