@@ -517,7 +517,7 @@ object Types {
517
517
def goApply (tp : HKApply ) = tp.tycon match {
518
518
case tl : TypeLambda =>
519
519
go(tl.resType).mapInfo(info =>
520
- tl.derivedTypeLambda (tl.paramNames, tl.paramBounds, info).appliedTo(tp.args))
520
+ tl.derivedLambdaAbstraction (tl.paramNames, tl.paramBounds, info).appliedTo(tp.args))
521
521
case _ =>
522
522
go(tp.superType)
523
523
}
@@ -879,12 +879,6 @@ object Types {
879
879
case _ => this
880
880
}
881
881
882
- /** If this is a TypeAlias type, its alias, otherwise this type itself */
883
- final def followTypeAlias (implicit ctx : Context ): Type = this match {
884
- case TypeAlias (alias) => alias
885
- case _ => this
886
- }
887
-
888
882
/** If this is a (possibly aliased, annotated, and/or parameterized) reference to
889
883
* a class, the class type ref, otherwise NoType.
890
884
* @param refinementOK If `true` we also skip non-parameter refinements.
@@ -1923,13 +1917,9 @@ object Types {
1923
1917
}
1924
1918
1925
1919
object TypeRef {
1926
- def checkProjection (prefix : Type , name : TypeName )(implicit ctx : Context ) = ()
1927
-
1928
1920
/** Create type ref with given prefix and name */
1929
- def apply (prefix : Type , name : TypeName )(implicit ctx : Context ): TypeRef = {
1930
- if (Config .checkProjections) checkProjection(prefix, name)
1921
+ def apply (prefix : Type , name : TypeName )(implicit ctx : Context ): TypeRef =
1931
1922
ctx.uniqueNamedTypes.enterIfNew(prefix, name).asInstanceOf [TypeRef ]
1932
- }
1933
1923
1934
1924
/** Create type ref to given symbol */
1935
1925
def apply (prefix : Type , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
@@ -1938,10 +1928,8 @@ object Types {
1938
1928
/** Create a non-member type ref (which cannot be reloaded using `member`),
1939
1929
* with given prefix, name, and symbol.
1940
1930
*/
1941
- def withFixedSym (prefix : Type , name : TypeName , sym : TypeSymbol )(implicit ctx : Context ): TypeRef = {
1942
- if (Config .checkProjections) checkProjection(prefix, name)
1931
+ def withFixedSym (prefix : Type , name : TypeName , sym : TypeSymbol )(implicit ctx : Context ): TypeRef =
1943
1932
unique(new TypeRefWithFixedSym (prefix, name, sym))
1944
- }
1945
1933
1946
1934
/** Create a type ref referring to given symbol with given name.
1947
1935
* This is very similar to TypeRef(Type, Symbol),
@@ -2057,9 +2045,7 @@ object Types {
2057
2045
private def badInst =
2058
2046
throw new AssertionError (s " bad instantiation: $this" )
2059
2047
2060
- def checkInst (implicit ctx : Context ): this .type = {
2061
- this
2062
- }
2048
+ def checkInst (implicit ctx : Context ): this .type = this // debug hook
2063
2049
2064
2050
def derivedRefinedType (parent : Type , refinedName : Name , refinedInfo : Type )(implicit ctx : Context ): Type =
2065
2051
if ((parent eq this .parent) && (refinedName eq this .refinedName) && (refinedInfo eq this .refinedInfo)) this
@@ -2139,7 +2125,7 @@ object Types {
2139
2125
override def computeHash = doHash(parent)
2140
2126
override def toString = s " RecType( $parent | $hashCode) "
2141
2127
2142
- private def checkInst (implicit ctx : Context ): this .type = this
2128
+ private def checkInst (implicit ctx : Context ): this .type = this // debug hook
2143
2129
}
2144
2130
2145
2131
object RecType {
@@ -2550,8 +2536,8 @@ object Types {
2550
2536
case _ => false
2551
2537
}
2552
2538
2553
- def derivedPolyType (paramNames : List [TypeName ], paramBounds : List [TypeBounds ], resType : Type )(implicit ctx : Context ) =
2554
- derivedGenericType(paramNames, paramBounds, resType)
2539
+ def derivedPolyType (paramNames : List [TypeName ], paramBounds : List [TypeBounds ], resType : Type )(implicit ctx : Context ): PolyType =
2540
+ derivedGenericType(paramNames, paramBounds, resType). asInstanceOf [ PolyType ]
2555
2541
2556
2542
def duplicate (paramNames : List [TypeName ] = this .paramNames, paramBounds : List [TypeBounds ] = this .paramBounds, resType : Type )(implicit ctx : Context ): PolyType =
2557
2543
PolyType (paramNames)(
@@ -2591,7 +2577,7 @@ object Types {
2591
2577
lazy val typeParams : List [LambdaParam ] =
2592
2578
paramNames.indices.toList.map(new LambdaParam (this , _))
2593
2579
2594
- def derivedTypeLambda (paramNames : List [TypeName ] = paramNames , paramBounds : List [TypeBounds ] = paramBounds , resType : Type )(implicit ctx : Context ): Type =
2580
+ def derivedLambdaAbstraction (paramNames : List [TypeName ], paramBounds : List [TypeBounds ], resType : Type )(implicit ctx : Context ): Type =
2595
2581
resType match {
2596
2582
case resType @ TypeAlias (alias) =>
2597
2583
resType.derivedTypeAlias(duplicate(paramNames, paramBounds, alias))
@@ -2600,9 +2586,12 @@ object Types {
2600
2586
if (lo.isRef(defn.NothingClass )) lo else duplicate(paramNames, paramBounds, lo),
2601
2587
duplicate(paramNames, paramBounds, hi))
2602
2588
case _ =>
2603
- derivedGenericType (paramNames, paramBounds, resType)
2589
+ derivedTypeLambda (paramNames, paramBounds, resType)
2604
2590
}
2605
2591
2592
+ def derivedTypeLambda (paramNames : List [TypeName ] = paramNames, paramBounds : List [TypeBounds ] = paramBounds, resType : Type )(implicit ctx : Context ): TypeLambda =
2593
+ derivedGenericType(paramNames, paramBounds, resType).asInstanceOf [TypeLambda ]
2594
+
2606
2595
def duplicate (paramNames : List [TypeName ] = this .paramNames, paramBounds : List [TypeBounds ] = this .paramBounds, resType : Type )(implicit ctx : Context ): TypeLambda =
2607
2596
TypeLambda (paramNames, variances)(
2608
2597
x => paramBounds mapConserve (_.subst(this , x).bounds),
@@ -2664,6 +2653,7 @@ object Types {
2664
2653
cachedSuper
2665
2654
}
2666
2655
2656
+ /* (Not needed yet) */
2667
2657
def lowerBound (implicit ctx : Context ) = tycon.stripTypeVar match {
2668
2658
case tycon : TypeRef =>
2669
2659
tycon.info match {
@@ -2676,13 +2666,6 @@ object Types {
2676
2666
NoType
2677
2667
}
2678
2668
2679
- /*
2680
- def lowerBound(implicit ctx: Context): Type = tycon.stripTypeVar match {
2681
- case tp: TypeRef =>
2682
- val lb = tp.info.bounds.lo.typeParams.length == args.lengt
2683
- case _ => defn.NothingType
2684
- }
2685
- */
2686
2669
def typeParams (implicit ctx : Context ): List [TypeParamInfo ] = {
2687
2670
val tparams = tycon.typeParams
2688
2671
if (tparams.isEmpty) TypeLambda .any(args.length).typeParams else tparams
@@ -2705,7 +2688,7 @@ object Types {
2705
2688
case _ =>
2706
2689
assert(false , s " illegal type constructor in $this" )
2707
2690
}
2708
- check(tycon)
2691
+ if ( Config .checkHKApplications) check(tycon)
2709
2692
this
2710
2693
}
2711
2694
}
0 commit comments