diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-08-12 13:02:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 13:02:18 -0700 |
commit | 5429e1dec30095893dd92ecfbb6b5775f607aa35 (patch) | |
tree | 07ba909dbb0ae247775f9fc1f4d135afd017a235 | |
parent | 62348dea92476f1bbb9d7f163f168be9c7e189b5 (diff) | |
parent | 4b3dce64270144cc4227452ca71d4ceff2a05555 (diff) | |
download | dotty-5429e1dec30095893dd92ecfbb6b5775f607aa35.tar.gz dotty-5429e1dec30095893dd92ecfbb6b5775f607aa35.tar.bz2 dotty-5429e1dec30095893dd92ecfbb6b5775f607aa35.zip |
Merge pull request #1448 from dotty-staging/fix/object-subtyping
Fix #1447: Make X$ <:< X.type when X is an object
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 8 | ||||
-rw-r--r-- | tests/pos/i1447.scala | 10 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 18eb424bc..d6ada7244 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -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 || diff --git a/tests/pos/i1447.scala b/tests/pos/i1447.scala new file mode 100644 index 000000000..661fc3917 --- /dev/null +++ b/tests/pos/i1447.scala @@ -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 +} |