aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Types.overflow
blob: 77f1f6fc195bd9d904ca90979cdb194bff8f8c10 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
object Types {
  class Type {
  
    /** The non-private symbol with given name in the given class that matches this type.
     *  @param inClass   The class containing the symbol's definition
     *  @param name      The name of the symbol we are looking for
     *  @param site      The base type from which member types are computed
    def matchingTermSymbol(inClass: Symbol, name: Name, site: Type)(implicit ctx: Context): Symbol = {
      var denot = inClass.info.nonPrivateDecl(name)
      if (denot.isTerm) { // types of the same name always match
        if (denot.isOverloaded)
          denot = denot.atSignature(this.signature) // seems we need two kinds of signatures here
        if (!(site.memberInfo(denot.symbol) matches this))
          denot = NoDenotation
      }
      denot.symbol
    }   
    
    final def firstParamTypes: List[Type] = this match {
      case mt: MethodType => mt.paramTypes
      case pt: PolyType => pt.firstParamTypes
      case _ => Nil
    }
    
    /** `tp` is either a type variable or poly param. Returns
     *  Covariant      if all occurrences of `tp` in this type are covariant
     *  Contravariant  if all occurrences of `tp` in this type are contravariant
     *  Covariant | Contravariant  if there are no occurrences of `tp` in this type
     *  EmptyFlags     if `tp` occurs noon-variantly in this type
     */
    def varianceOf(tp: Type): FlagSet = ???

    
  }
  
  class AndType extends Type {
  
    def derived_& (tp1: Type, tp2: Type)(implicit ctx: Context) =
      if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this
      else tp1 & tp2
  
  }
  
  class OrType extends Type {
  
    def derived_| (tp1: Type, tp2: Type)(implicit ctx: Context) =
      if ((tp1 eq this.tp1) && (tp2 eq this.tp2)) this
      else tp1 | tp2
      
  }
  
  class MethodType {
    /* probably won't be needed
    private var _isVarArgs: Boolean = _
    private var knownVarArgs: Boolean = false

    def isVarArgs(implicit ctx: Context) = {
      if (!knownVarArgs) {
        _isVarArgs = paramTypes.nonEmpty && paramTypes.last.isRepeatedParam
        knownVarArgs = true
      }
      _isVarArgs
    }
    */
  }
}