@@ -11,6 +11,7 @@ import Scopes.Scope
1111import dotty .tools .io .AbstractFile
1212import Decorators .SymbolIteratorDecorator
1313import ast ._
14+ import ast .Trees .{LambdaTypeTree , TypeBoundsTree }
1415import Trees .Literal
1516import Variances .Variance
1617import annotation .tailrec
@@ -433,8 +434,9 @@ object SymDenotations {
433434 *
434435 * @param info Is assumed to be a (lambda-abstracted) right hand side TypeAlias
435436 * of the opaque type definition.
437+ * @param rhs The right hand side tree of the type definition
436438 */
437- def opaqueToBounds (info : Type )(given Context ): Type =
439+ def opaqueToBounds (info : Type , rhs : tpd. Tree )(given Context ): Type =
438440
439441 def setAlias (tp : Type ) =
440442 def recur (self : Type ): Unit = self match
@@ -446,21 +448,19 @@ object SymDenotations {
446448 recur(owner.asClass.givenSelfType)
447449 end setAlias
448450
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)
456457 case _ =>
457- (tp, HKTypeLambda .boundsFromParams(tp.typeParams, TypeBounds .empty))
458+ TypeBounds .empty
458459
459460 info match
460- case TypeAlias (tp) if isOpaqueAlias && owner.isClass =>
461- val (alias, bounds) = split(tp)
461+ case TypeAlias (alias) if isOpaqueAlias && owner.isClass =>
462462 setAlias(alias)
463- bounds
463+ HKTypeLambda .boundsFromParams(alias.typeParams, bounds(rhs))
464464 case _ =>
465465 info
466466 end opaqueToBounds
0 commit comments