From 8552740beda9bb07de1da329e9dc8c002090fe16 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Sat, 17 Mar 2012 12:18:43 +0100 Subject: [vpm] pack types of if branches before lubbing this way we don't end up with fresh, incompatible, skolems for every branch, but a neatly packed existential you get much nicer lubs this way -- threw in a fast path (I hope) that avoids lubbing when unnecessary (same types) since lub isn't robust enough to deal with the result of packedType, and we only really need the trivial case (S =:= T), special case it for now ... don't pack in ifs after typer, also only when virtPatmat --- src/compiler/scala/tools/nsc/typechecker/Typers.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index daf4ddd100..ad48712a32 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3566,7 +3566,15 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } else { var thenp1 = typed(thenp, pt) var elsep1 = typed(elsep, pt) - val (owntype, needAdapt) = ptOrLub(List(thenp1.tpe, elsep1.tpe)) + + lazy val thenTp = packedType(thenp1, context.owner) + lazy val elseTp = packedType(elsep1, context.owner) + val (owntype, needAdapt) = + // virtpatmat needs more aggressive unification of skolemized types, but lub is not robust enough --> middle ground + if (opt.virtPatmat && !isPastTyper && thenTp =:= elseTp) (thenTp, true) // this breaks src/library/scala/collection/immutable/TrieIterator.scala + // TODO: skolemize (lub of packed types) when that no longer crashes on files/pos/t4070b.scala + else ptOrLub(List(thenp1.tpe, elsep1.tpe)) + if (needAdapt) { //isNumericValueType(owntype)) { thenp1 = adapt(thenp1, mode, owntype) elsep1 = adapt(elsep1, mode, owntype) -- cgit v1.2.3