@@ -11,6 +11,7 @@ import Scopes.Scope
11
11
import dotty .tools .io .AbstractFile
12
12
import Decorators .SymbolIteratorDecorator
13
13
import ast ._
14
+ import ast .Trees .{LambdaTypeTree , TypeBoundsTree }
14
15
import Trees .Literal
15
16
import Variances .Variance
16
17
import annotation .tailrec
@@ -433,8 +434,9 @@ object SymDenotations {
433
434
*
434
435
* @param info Is assumed to be a (lambda-abstracted) right hand side TypeAlias
435
436
* of the opaque type definition.
437
+ * @param rhs The right hand side tree of the type definition
436
438
*/
437
- def opaqueToBounds (info : Type )(given Context ): Type =
439
+ def opaqueToBounds (info : Type , rhs : tpd. Tree )(given Context ): Type =
438
440
439
441
def setAlias (tp : Type ) =
440
442
def recur (self : Type ): Unit = self match
@@ -446,21 +448,19 @@ object SymDenotations {
446
448
recur(owner.asClass.givenSelfType)
447
449
end setAlias
448
450
449
- def split (tp : Type ): (Type , TypeBounds ) = tp match
450
- case AnnotatedType (alias, Annotation .WithBounds (bounds)) =>
451
- (alias, bounds)
452
- case tp : HKTypeLambda =>
453
- val (alias1, bounds1) = split(tp.resType)
454
- (tp.derivedLambdaType(resType = alias1),
455
- HKTypeLambda .boundsFromParams(tp.typeParams, bounds1))
451
+ def bounds (t : tpd.Tree ): TypeBounds = t match
452
+ case LambdaTypeTree (_, body) =>
453
+ bounds(body)
454
+ case TypeBoundsTree (lo, hi, alias) =>
455
+ assert(! alias.isEmpty)
456
+ TypeBounds (lo.tpe, hi.tpe)
456
457
case _ =>
457
- (tp, HKTypeLambda .boundsFromParams(tp.typeParams, TypeBounds .empty))
458
+ TypeBounds .empty
458
459
459
460
info match
460
- case TypeAlias (tp) if isOpaqueAlias && owner.isClass =>
461
- val (alias, bounds) = split(tp)
461
+ case TypeAlias (alias) if isOpaqueAlias && owner.isClass =>
462
462
setAlias(alias)
463
- bounds
463
+ HKTypeLambda .boundsFromParams(alias.typeParams, bounds(rhs))
464
464
case _ =>
465
465
info
466
466
end opaqueToBounds
0 commit comments