@@ -1460,13 +1460,13 @@ object Types {
1460
1460
case _ => this
1461
1461
}
1462
1462
1463
- /** Follow aliases and dereferences LazyRefs, annotated types and instantiated
1463
+ /** Follow aliases and dereference LazyRefs, annotated types and instantiated
1464
1464
* TypeVars until type is no longer alias type, annotated type, LazyRef,
1465
1465
* or instantiated type variable.
1466
1466
*/
1467
1467
final def dealias (using Context ): Type = dealias1(keepNever, keepOpaques = false )
1468
1468
1469
- /** Follow aliases and dereferences LazyRefs and instantiated TypeVars until type
1469
+ /** Follow aliases and dereference LazyRefs and instantiated TypeVars until type
1470
1470
* is no longer alias type, LazyRef, or instantiated type variable.
1471
1471
* Goes through annotated types and rewraps annotations on the result.
1472
1472
*/
@@ -1475,12 +1475,30 @@ object Types {
1475
1475
/** Like `dealiasKeepAnnots`, but keeps only refining annotations */
1476
1476
final def dealiasKeepRefiningAnnots (using Context ): Type = dealias1(keepIfRefining, keepOpaques = false )
1477
1477
1478
- /** Follow non-opaque aliases and dereferences LazyRefs, annotated types and instantiated
1479
- * TypeVars until type is no longer alias type, annotated type, LazyRef,
1480
- * or instantiated type variable.
1478
+ /** Like dealias, but does not follow aliases if symbol is Opaque. This is
1479
+ * necessary if we want to look at the info of a symbol containing opaque
1480
+ * type aliases but pretend "it's from the outside". For instance, consider:
1481
+ *
1482
+ * opaque type IArray[T] = Array[? <: T]
1483
+ * object IArray:
1484
+ * def head[T](xs: IArray[T]): T = ???
1485
+ *
1486
+ * If we dealias types in the info of `head`, those types appear with prefix
1487
+ * IArray.this, where IArray's self type is `IArray { type IArray[T] = Array[? <: T] }`.
1488
+ * Hence, if we see IArray it will appear as an alias of [T] =>> Array[? <: T].
1489
+ * But if we want to see the type from the outside of object IArray we need to
1490
+ * suppress this dealiasing. A test case where this matters is i18909.scala.
1491
+ * Here, we dealias symbol infos at the start of capture checking in operation `fluidify`.
1492
+ * We have to be careful not to accidentally reveal opqaue aliases when doing so.
1481
1493
*/
1482
1494
final def dealiasKeepOpaques (using Context ): Type = dealias1(keepNever, keepOpaques = true )
1483
1495
1496
+ /** Like dealiasKeepAnnots, but does not follow opaque aliases. See `dealiasKeepOpaques`
1497
+ * for why this is sometimes necessary.
1498
+ */
1499
+ final def dealiasKeepAnnotsAndOpaques (using Context ): Type =
1500
+ dealias1(keepAlways, keepOpaques = true )
1501
+
1484
1502
/** Approximate this type with a type that does not contain skolem types. */
1485
1503
final def deskolemized (using Context ): Type =
1486
1504
val deskolemizer = new ApproximatingTypeMap {
@@ -5351,6 +5369,8 @@ object Types {
5351
5369
case that : AliasingBounds => this .isTypeAlias == that.isTypeAlias && alias.eq(that.alias)
5352
5370
case _ => false
5353
5371
}
5372
+
5373
+ override def toString = s " ${getClass.getSimpleName}( $alias) "
5354
5374
}
5355
5375
5356
5376
/** = T
0 commit comments