@@ -557,16 +557,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
557
557
* definition!
558
558
*/
559
559
def refine (tp1 : Type , tp2 : Type ): Type = (tp1, tp2) match {
560
- case (tp1 : RefinedType , _ : TypeRef ) =>
561
- val res = tp1.wrapIfMember(refine(tp1.parent, tp2))
562
- debug.println(i " refine( $tp1, $tp2) = $res" )
563
- res
564
- case (tp1 @ AppliedType (tycon, args), tp2 : TypeRef )
565
- if tp2.symbol.typeParams.nonEmpty && tp2.symbol.derivesFrom(tycon.typeSymbol) =>
566
- val tp1a = tp1.derivedAppliedType(refine(tycon, tp2), args)
567
- val res = derivingType(tp1a.asInstanceOf [AppliedType ], tp2)
568
- debug.println(i " refine( $tp1, $tp2) = $res" )
569
- res
560
+ case (tp1 : RefinedType , _ : TypeRef ) => tp1.wrapIfMember(refine(tp1.parent, tp2))
570
561
case (tp1 : AppliedType , _) => refine(tp1.superType, tp2)
571
562
case (TypeRef (ref1 : TypeProxy , _), tp2 @ TypeRef (ref2 : TypeProxy , _)) =>
572
563
if (ref1.underlying <:< ref2.underlying) tp2.derivedSelect(ref1) else tp2
@@ -575,54 +566,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
575
566
case _ => tp2
576
567
}
577
568
578
- /** This might be useful for adapting to the new applied type scheme: */
579
-
580
- import TypeApplications ._
581
- import typer .ProtoTypes .constrained
582
- import ast .untpd
583
-
584
- /** If `clsRef` is a subclass of `tp1`, the largest class type of the form
585
- *
586
- * pre.<clsRef>[args]
587
- *
588
- * which is a subtype of `tp1`.
589
- */
590
- def derivingType (tp1 : AppliedType , clsRef : TypeRef ): Type = {
591
- val cls = clsRef.symbol
592
- val typeParams = cls.typeParams
593
- if (tp1.tycon.typeSymbol == cls) tp1
594
- else {
595
- val abstracted = PolyType .fromParams(
596
- cls.typeParams, clsRef.appliedTo(typeParams.map(_.typeRef))).asInstanceOf [PolyType ]
597
- val (schema, _) = constrained(abstracted, untpd.EmptyTree )
598
- schema <:< tp1
599
- val constraint = ctx.typerState.constraint
600
- def avoidParamRefs (seen : Set [TypeParamRef ], v : Int ): ApproximatingTypeMap = new ApproximatingTypeMap {
601
- variance = if (v >= 0 ) 1 else - 1
602
- def apply (t : Type ) = t match {
603
- case t : TypeParamRef if schema.paramRefs contains t =>
604
- val lo = atVariance(- variance)(apply(constraint.fullLowerBound(t)))
605
- val hi =
606
- if (seen.contains(t)) t.topType
607
- else avoidParamRefs(seen + t, variance)(constraint.fullUpperBound(t))
608
- range(lo, hi)
609
- case _ => mapOver(t)
610
- }
611
- }
612
- val boundss = abstracted.paramRefs.map(constraint.fullBounds)
613
- def boundsToArg (bounds : TypeBounds , tparam : TypeSymbol ): Type = {
614
- val v = tparam.paramVariance
615
- val arg =
616
- if (v < 0 || (bounds.hi frozen_<:< bounds.lo)) bounds.lo
617
- else if (v > 0 ) bounds.hi
618
- else bounds
619
- avoidParamRefs(Set .empty, v)(arg)
620
- }
621
- val args = (boundss, typeParams).zipped.map(boundsToArg)
622
- clsRef.appliedTo(args)
623
- }
624
- }
625
-
626
569
/** Abstract sealed types, or-types, Boolean and Java enums can be decomposed */
627
570
def canDecompose (tp : Type ): Boolean = {
628
571
val dealiasedTp = tp.dealias
0 commit comments