diff options
author | Dmitry Petrashko <dark@d-d.me> | 2016-07-31 17:30:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-31 17:30:46 -0700 |
commit | a0ad3f1d020cc3f3f37bc887874517ace670bf52 (patch) | |
tree | 244c2d44db0ccfbcd5d79d55fe1326da7e934e32 | |
parent | ed05cbaaf0192a44c0b934eb94215dceff4f3dbe (diff) | |
parent | 3c3b32346f2c4eafe26cc9659b41ae50b0316b92 (diff) | |
download | dotty-a0ad3f1d020cc3f3f37bc887874517ace670bf52.tar.gz dotty-a0ad3f1d020cc3f3f37bc887874517ace670bf52.tar.bz2 dotty-a0ad3f1d020cc3f3f37bc887874517ace670bf52.zip |
Merge pull request #1398 from dotty-staging/fix-#1269
Fix #1269: Typing and pattern matching of nested subclasses
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/PatternMatcher.scala | 3 | ||||
-rw-r--r-- | tests/pos/i1269.scala | 16 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 054c67e7e..3e04e9c77 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2995,10 +2995,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 = { @@ -3018,7 +3014,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 } diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala index 974053769..92d638be9 100644 --- a/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -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` diff --git a/tests/pos/i1269.scala b/tests/pos/i1269.scala new file mode 100644 index 000000000..c0b56e1ea --- /dev/null +++ b/tests/pos/i1269.scala @@ -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() => + } +} |