diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 2 | ||||
-rw-r--r-- | test/files/pos/bug845.scala | 16 |
3 files changed, 20 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 01cf3fdec0..844d74cea5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -685,9 +685,9 @@ trait Types requires SymbolTable { val pci = pclosure(i) if (j < pci.length) pci(j) else AnyClass.tpe } - val limit = pclosure(0).length - while (index(0) != limit) { - var minSym: Symbol = nextBaseType(0).symbol + var minSym: Symbol = NoSymbol + while (minSym != AnyClass) { + minSym = nextBaseType(0).symbol i = 1 while (i < nparents) { if (nextBaseType(i).symbol isLess minSym) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 0e118028db..0428161cc2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -162,8 +162,8 @@ trait Infer requires Analyzer { tparam2.tpe.subst(tparams, tvars) :: tvar.constr.lobounds } } - //Console.println("solveOne2 "+tvar+" "+config+" "+tvar.constr.hibounds);//DEBUG tvar.constr.inst = NoType // necessary because hibounds/lobounds may contain tvar + //Console.println("solving "+tvar+" "+up+" "+(if (up) (tvar.constr.hibounds) else tvar.constr.lobounds))//DEBUG tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds) assertNonCyclic(tvar)//debug } diff --git a/test/files/pos/bug845.scala b/test/files/pos/bug845.scala new file mode 100644 index 0000000000..c8a2faa671 --- /dev/null +++ b/test/files/pos/bug845.scala @@ -0,0 +1,16 @@ +package test; + +object Test extends Application { + type Bar; + trait FooImpl; + + trait Bob { + def bar : Bar with FooImpl; + } + def ifn[A,B](a : A)(f : A => B) = + if (a != null) f(a) else null; + + val bob : Bob = null; + val bar = ifn(bob)(.bar); + assert(bar == null); +} |