diff options
-rw-r--r-- | sources/scala/tools/scalac/typechecker/Analyzer.scala | 4 | ||||
-rwxr-xr-x | test/files/pos/viewtest2.scala | 24 |
2 files changed, 27 insertions, 1 deletions
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala index 37b3ae2379..e9b45b6c3e 100644 --- a/sources/scala/tools/scalac/typechecker/Analyzer.scala +++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala @@ -575,13 +575,14 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer( val vapp = transform( make.Apply(tree.pos, vexpr, NewArray.Tree(tree)), mode, pt); if (v.symtype.isObjectType()) { + val tree1 = transform(tree.duplicate(), mode, pt); gen.If( gen.Apply( gen.Select( vexpr.duplicate(), definitions.ANY_EQEQ), NewArray.Tree(gen.mkNullLit(tree.pos))), - gen.mkNullLit(tree.pos), + tree1, vapp) } else vapp } @@ -1649,6 +1650,7 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer( if (v != null) { qual = applyView( v, qual.setType(qual.getType().singleDeref()), EXPRmode, Type.AnyType); + System.out.println("app view " + qual + ":" + qual.getType());//debug sym = qual.getType().lookup(name); assert(sym.kind != NONE); } else { diff --git a/test/files/pos/viewtest2.scala b/test/files/pos/viewtest2.scala index aa8d33ed6c..880ee2a57a 100755 --- a/test/files/pos/viewtest2.scala +++ b/test/files/pos/viewtest2.scala @@ -1,6 +1,29 @@ package test; +/** A trait for totally ordered data. + */ +trait Ordered[+a] { + + /** Result of comparing `this' with operand `that'. + * returns `x' where + * x < 0 iff this < that + * x == 0 iff this == that + * x > 0 iff this > that + */ + def compareTo [b >: a <% Ordered[b]](that: b): int; + + def < [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) < 0; + + def > [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) > 0; + + def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0; + + def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0; +} + + object O { + def view (x: String): Ordered[String] = new Ordered[String] { def compareTo [b >: String <% Ordered[b]](y: b): int = y match { case y1: String => x compareTo y1; @@ -13,6 +36,7 @@ object O { case _ => -(y compareTo x) } } + def view[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] { def compareTo [b >: List[a] <% Ordered[b]](y: b): int = y match { |