Permalink
Browse files

fixes a problem with an extractor object overloaded by a regular def

  • Loading branch information...
xeno-by committed May 9, 2012
1 parent 2422b06 commit 82f3e49b37043e9f7661a43fe28c158dec4a3f31
@@ -2663,6 +2663,10 @@ trait Types extends api.Types { self: SymbolTable =>
override def kind = "OverloadedType"
}
def overloadedType(pre: Type, alternatives: List[Symbol]): Type =
if (alternatives.tail.isEmpty) pre memberType alternatives.head
else OverloadedType(pre, alternatives)
/** A class remembering a type instantiation for some a set of overloaded
* polymorphic symbols.
* Not used after phase `typer`.
@@ -958,9 +958,14 @@ trait Typers extends Modes with Adaptations with Taggings {
* see test/files/../t5189*.scala
*/
def adaptConstrPattern(): Tree = { // (5)
val extractor = tree.symbol.filter(sym => reallyExists(unapplyMember(sym.tpe)))
def isExtractor(sym: Symbol) = reallyExists(unapplyMember(sym.tpe))
val extractor = tree.symbol filter isExtractor
if (extractor != NoSymbol) {
tree setSymbol extractor
tree.tpe match {
case OverloadedType(pre, alts) => tree.tpe = overloadedType(pre, alts filter isExtractor)
case _ =>
}
val unapply = unapplyMember(extractor.tpe)
val clazz = unapplyParameterType(unapply)
@@ -0,0 +1,32 @@
trait TreesBase {
type Tree
type Apply <: Tree
val Apply: ApplyExtractor
abstract class ApplyExtractor {
def apply(x: Int): Apply
def unapply(apply: Apply): Option[Int]
}
}
trait TreesApi extends TreesBase {
def Apply(x: String)
}
class Universe extends TreesApi {
abstract class Tree
case class Apply(x: Int) extends Tree
object Apply extends ApplyExtractor
def Apply(x: String) = Apply(x.toInt)
}
object Test extends App {
def foo(tapi: TreesApi) {
import tapi._
def bar(tree: Tree) {
val Apply(x) = tree
}
}
}

0 comments on commit 82f3e49

Please sign in to comment.