Skip to content

Fix #1269: Typing and pattern matching of nested subclasses #1398

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 2 commits into from
Aug 1, 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
6 changes: 1 addition & 5 deletions src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2993,10 +2993,6 @@ object Types {
/** The class type with all type parameters */
def fullyAppliedRef(implicit ctx: Context): Type = fullyAppliedRef(cls.typeRef, cls.typeParams)

def rebase(tp: Type)(implicit ctx: Context): Type =
if ((prefix eq cls.owner.thisType) || !cls.owner.isClass || ctx.erasedTypes) tp
else tp.substThis(cls.owner.asClass, prefix)

private var typeRefCache: TypeRef = null

def typeRef(implicit ctx: Context): TypeRef = {
Expand All @@ -3016,7 +3012,7 @@ object Types {
/** The parent type refs as seen from the given prefix */
override def parents(implicit ctx: Context): List[TypeRef] = {
if (parentsCache == null)
parentsCache = cls.classParents.mapConserve(rebase(_).asInstanceOf[TypeRef])
parentsCache = cls.classParents.mapConserve(_.asSeenFrom(prefix, cls.owner).asInstanceOf[TypeRef])
parentsCache
}

Expand Down
3 changes: 1 addition & 2 deletions src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans

def outerTest(testedBinder: Symbol, expectedTp: Type): Tree = {
val expectedOuter = expectedTp.normalizedPrefix match {
//case ThisType(clazz) => This(clazz)
//case NoType => Literal(Constant(true)) // fallback for SI-6183 todo?
case pre => ref(pre.termSymbol)
case pre: SingletonType => singleton(pre)
}

// ExplicitOuter replaces `Select(q, outerSym) OBJ_EQ expectedPrefix` by `Select(q, outerAccessor(outerSym.owner)) OBJ_EQ expectedPrefix`
Expand Down
16 changes: 16 additions & 0 deletions tests/pos/i1269.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trait Module {
sealed abstract class Tree

case class LetL() extends Tree

object O {
case class LetR() extends Tree
}
}

class Patmat(val module: Module) {
def patmat(tree: module.Tree) = tree match {
case module.LetL() =>
case module.O.LetR() =>
}
}