diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-13 10:24:15 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-11-22 12:24:43 +0100 |
commit | a5e24768f26bb2d28c7610ff5a184b0c65f56c55 (patch) | |
tree | e6689b942a0f5860d64e7d2e7d1d2f7b37f95e0c /src | |
parent | 7bdb3f1b2518db9510d709da1d6ae6542d235b65 (diff) | |
download | scala-a5e24768f26bb2d28c7610ff5a184b0c65f56c55.tar.gz scala-a5e24768f26bb2d28c7610ff5a184b0c65f56c55.tar.bz2 scala-a5e24768f26bb2d28c7610ff5a184b0c65f56c55.zip |
SI-7967 Account for type aliases in self-type checks
These eluded the check for "illegal inheritance; self-type does not
conform" as AliasTypeRef doesn't forward `typeOfThis`.
This commit dealiases before calling `typeOfThis`. That seems to be
the most localised change.
Without the dealias, we had:
parent.tpe = TypeRef(pre, sym = AliasTypeSymbol("CC"), Nil)
parent.tpe.typeOfThis = parent.tpe.transform(sym.typeOfThis) = CC
After:
parent.tpe.dealias = TypeRef(pre, sym = ClassSymbol("C"), Nil)
parent.tpe.dealias.typeOfThis = C with B
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a9bb81c691..f90c6f1d86 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1698,15 +1698,16 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper psym addChild context.owner else pending += ParentSealedInheritanceError(parent, psym) + val parentTypeOfThis = parent.tpe.dealias.typeOfThis - if (!(selfType <:< parent.tpe.typeOfThis) && + if (!(selfType <:< parentTypeOfThis) && !phase.erasedTypes && !context.owner.isSynthetic && // don't check synthetic concrete classes for virtuals (part of DEVIRTUALIZE) !selfType.isErroneous && !parent.tpe.isErroneous) { pending += ParentSelfTypeConformanceError(parent, selfType) - if (settings.explaintypes) explainTypes(selfType, parent.tpe.typeOfThis) + if (settings.explaintypes) explainTypes(selfType, parentTypeOfThis) } if (parents exists (p => p != parent && p.tpe.typeSymbol == psym && !psym.isError)) |