Permalink
Browse files

Keep annotations when computing lubs

Integrates annotationsLub into lub.

Also fixes SubstSymMap when mapping over annotaion trees. I don't
understand what the previous code was supposed to achieve, but it
crashed in some of my examples.
  • Loading branch information...
1 parent 6697c28 commit a06d31f6a2df021acc18b10ad9cad0f80d7498f2 @lrytz lrytz committed Jan 29, 2013
Showing with 12 additions and 17 deletions.
  1. +9 −17 src/reflect/scala/reflect/internal/Types.scala
  2. +3 −0 test/files/pos/lubs.scala
@@ -4706,23 +4706,13 @@ trait Types extends api.Types { self: SymbolTable =>
case idx => Some(to(idx))
}
- override def transform(tree: Tree) =
- tree match {
- case tree@Ident(_) =>
- termMapsTo(tree.symbol) match {
- case Some(tosym) =>
- if (tosym.info.bounds.hi.typeSymbol isSubClass SingletonClass) {
- Ident(tosym.existentialToString)
- .setSymbol(tosym)
- .setPos(tosym.pos)
- .setType(dropSingletonType(tosym.info.bounds.hi))
- } else {
- giveup()
- }
- case none => super.transform(tree)
- }
- case tree => super.transform(tree)
+ override def transform(tree: Tree) = {
+ termMapsTo(tree.symbol) match {
+ case Some(tosym) => tree.symbol = tosym
+ case None => ()
}
+ super.transform(tree)
+ }
}
trans.transform(tree)
}
@@ -6618,7 +6608,7 @@ trait Types extends api.Types { self: SymbolTable =>
val ts0 = elimSub0(ts)
if (ts0.isEmpty || ts0.tail.isEmpty) ts0
else {
- val ts1 = ts0 mapConserve (t => elimAnonymousClass(t.underlying))
+ val ts1 = ts0 mapConserve (t => elimAnonymousClass(t.dealiasWiden))
if (ts1 eq ts0) ts0
else elimSub(ts1, depth)
}
@@ -6735,6 +6725,8 @@ trait Types extends api.Types { self: SymbolTable =>
NullaryMethodType(lub0(matchingRestypes(ts, Nil)))
case ts @ TypeBounds(_, _) :: rest =>
TypeBounds(glb(ts map (_.bounds.lo), depth), lub(ts map (_.bounds.hi), depth))
+ case ts @ AnnotatedType(annots, tpe, _) :: rest =>
+ annotationsLub(lub0(ts map (_.withoutAnnotations)), ts)
case ts =>
lubResults get (depth, ts) match {
case Some(lubType) =>
@@ -0,0 +1,3 @@
+object Test {
+ List(new { def f = 1; def g = 1}, new { def f = 2}).map(_.f)
+}

0 comments on commit a06d31f

Please sign in to comment.