summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/runtime/RuntimeTypes.scala
blob: 84d02ab7a066808104b0e9ed7d2bf4f871c566f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package scala.reflect
package runtime

import collection.mutable.ListBuffer

trait RuntimeTypes extends Universe with api.RuntimeTypes {

  /** To lift path dependent types into reflection, we use InstanceRefSymbols.
   *  Two of these are equal if they point to the same object reference. Todo: remove
   */
  case class InstanceRefSymbol(value: AnyRef) extends TermSymbol(NoSymbol, NoPosition, nme.EMPTY)
  object InstanceRefSymbol extends InstanceRefSymbolExtractor

  override private[reflect] def namedType(pre: Type, sym: Symbol, args: List[Type]): Type = {
    val tparamBuf = new ListBuffer[Symbol]
    val args1 = for (arg <- args) yield arg match {
      case _: TypeBounds =>
        val ex = pre.typeSymbol.freshExistential("$ex") setInfo arg
        tparamBuf += ex
        TypeRef(NoPrefix, ex, List())
      case _ =>
        arg
    }
    existentialAbstraction(tparamBuf.toList, typeRef(pre, sym, args1))
  }

}