From 1ba2d7bb967ded0c19ff2cf966c492adc12292bb Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 29 Apr 2014 14:38:35 +0200 Subject: SI-8546 Pattern matcher analysis foiled by over-widening In the enclosed test, the prefix checkable type `ModuleTypeRef(F2.this, C)` was being inadvertently widened to `ModuleTypeRef(F2[?], C)`. This started after some misguided future-proofing in SI-6771 / 3009916. This commit changes the `dealiasWiden` to a `delias`. --- src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index 2893cbdf45..894f959319 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -149,14 +149,15 @@ trait TreeAndTypeAnalysis extends Debugging { object typeArgsToWildcardsExceptArray extends TypeMap { // SI-6771 dealias would be enough today, but future proofing with the dealiasWiden. // See neg/t6771b.scala for elaboration - def apply(tp: Type): Type = tp.dealiasWiden match { + def apply(tp: Type): Type = tp.dealias match { case TypeRef(pre, sym, args) if args.nonEmpty && (sym ne ArrayClass) => TypeRef(pre, sym, args map (_ => WildcardType)) case _ => mapOver(tp) } } - debug.patmatResult(s"checkableType($tp)")(typeArgsToWildcardsExceptArray(tp)) + val result = typeArgsToWildcardsExceptArray(tp) + debug.patmatResult(s"checkableType($tp)")(result) } // a type is "uncheckable" (for exhaustivity) if we don't statically know its subtypes (i.e., it's unsealed) -- cgit v1.2.3