diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 15 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 00f4186805..f33f637a46 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package matching -import util.Position import transform.ExplicitOuter import symtab.Flags import collection._ @@ -188,6 +187,13 @@ trait ParallelMatching extends ast.TreeDSL } } + if (settings.Xmigration28.value) { + for (p <- ps ; if isArraySeqTest(scrut.tpe, p.tpe)) { + val reportPos = if (p.tree.pos.isDefined) p.tree.pos else scrut.pos + cunit.warning(reportPos, "An Array will no longer match as Seq[_].") + } + } + def mkRule(rest: Rep): RuleApplication = { tracing("Rule", head match { case x if isEquals(x.tree.tpe) => new MixEquals(this, rest) diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index c11bfd9703..f78022bdaa 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -61,6 +61,12 @@ abstract class ExplicitOuter extends InfoTransform result } + /** Issue a migration warning for instance checks which might be on an Array and + * for which the type parameter conforms to Seq, because these answers changed in 2.8. + */ + def isArraySeqTest(lhs: Type, rhs: Type) = + ArrayClass.tpe <:< lhs.widen && rhs.widen.matchesPattern(SeqClass.tpe) + def outerAccessor(clazz: Symbol): Symbol = { val firstTry = clazz.info.decl(nme.expandedName(nme.OUTER, clazz)) if (firstTry != NoSymbol && firstTry.outerSource == clazz) firstTry @@ -294,7 +300,6 @@ abstract class ExplicitOuter extends InfoTransform * </p> */ class ExplicitOuterTransformer(unit: CompilationUnit) extends OuterPathTransformer(unit) { - /** The definition tree of the outer accessor of current class */ def outerFieldDef: Tree = VAL(outerField(currentClass)) === EmptyTree @@ -483,8 +488,14 @@ abstract class ExplicitOuter extends InfoTransform matchTranslation(mch) case _ => - val x = super.transform(tree) + if (settings.Xmigration28.value) tree match { + case TypeApply(fn @ Select(qual, _), args) if fn.symbol == Object_isInstanceOf || fn.symbol == Any_isInstanceOf => + if (isArraySeqTest(qual.tpe, args.head.tpe)) + unit.warning(tree.pos, "An Array will no longer match as Seq[_].") + case _ => () + } + val x = super.transform(tree) if (x.tpe eq null) x else x setType transformInfo(currentOwner, x.tpe) } |