aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeParamInfo.scala
blob: 647c895db700f551ddb1b58cf88a3c828f505f3c (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
28
29
30
31
32
33
34
35
36
37
38
39
40
package dotty.tools.dotc.core

import Names.TypeName
import Contexts.Context
import Types.{Type, TypeBounds}

/** A common super trait of Symbol and LambdaParam.
 *  Used to capture the attributes of type parameters which can be implemented as either.
 */
trait TypeParamInfo {

  /** Is this the info of a type parameter? Will return `false` for symbols
   *  that are not type parameters.
   */
  def isTypeParam(implicit ctx: Context): Boolean

  /** The name of the type parameter */
  def paramName(implicit ctx: Context): TypeName

  /** The info of the type parameter */
  def paramBounds(implicit ctx: Context): TypeBounds

  /** The info of the type parameter as seen from a prefix type.
   *  For type parameter symbols, this is the `memberInfo` as seen from `prefix`.
   *  For type lambda parameters, it's the same as `paramBounds` as
   *  `asSeenFrom` has already been applied to the whole type lambda.
   */
  def paramBoundsAsSeenFrom(pre: Type)(implicit ctx: Context): TypeBounds

  /** The parameter bounds, or the completer if the type parameter
   *  is an as-yet uncompleted symbol.
   */
  def paramBoundsOrCompleter(implicit ctx: Context): Type

  /** The variance of the type parameter */
  def paramVariance(implicit ctx: Context): Int

  /** A type that refers to the parameter */
  def paramRef(implicit ctx: Context): Type
}