@@ -114,6 +114,7 @@ object Types {
114114 case _ : SingletonType | NoPrefix => true
115115 case tp : RefinedOrRecType => tp.parent.isStable
116116 case tp : ExprType => tp.resultType.isStable
117+ case tp : AnnotatedType => tp.tpe.isStable
117118 case _ => false
118119 }
119120
@@ -247,6 +248,9 @@ object Types {
247248 case _ => NoType
248249 }
249250
251+ /** Is this type a (possibly aliased) singleton type? */
252+ def isSingleton (implicit ctx : Context ) = dealias.isInstanceOf [SingletonType ]
253+
250254 /** Is this type guaranteed not to have `null` as a value? */
251255 final def isNotNull (implicit ctx : Context ): Boolean = this match {
252256 case tp : ConstantType => tp.value.value != null
@@ -354,7 +358,6 @@ object Types {
354358 @ tailrec final def typeSymbol (implicit ctx : Context ): Symbol = this match {
355359 case tp : TypeRef => tp.symbol
356360 case tp : ClassInfo => tp.cls
357- // case ThisType(cls) => cls // needed?
358361 case tp : SingletonType => NoSymbol
359362 case tp : TypeProxy => tp.underlying.typeSymbol
360363 case _ => NoSymbol
@@ -918,7 +921,7 @@ object Types {
918921 /** Widen from singleton type to its underlying non-singleton
919922 * base type by applying one or more `underlying` dereferences.
920923 */
921- final def widenSingleton (implicit ctx : Context ): Type = stripTypeVar match {
924+ final def widenSingleton (implicit ctx : Context ): Type = stripTypeVar.stripAnnots match {
922925 case tp : SingletonType if ! tp.isOverloaded => tp.underlying.widenSingleton
923926 case _ => this
924927 }
@@ -3555,16 +3558,18 @@ object Types {
35553558 // ----- Annotated and Import types -----------------------------------------------
35563559
35573560 /** An annotated type tpe @ annot */
3558- case class AnnotatedType (tpe : Type , annot : Annotation )
3559- extends UncachedProxyType with ValueType {
3561+ case class AnnotatedType (tpe : Type , annot : Annotation ) extends UncachedProxyType with ValueType {
35603562 // todo: cache them? but this makes only sense if annotations and trees are also cached.
3563+
35613564 override def underlying (implicit ctx : Context ): Type = tpe
3565+
35623566 def derivedAnnotatedType (tpe : Type , annot : Annotation ) =
35633567 if ((tpe eq this .tpe) && (annot eq this .annot)) this
35643568 else AnnotatedType (tpe, annot)
35653569
35663570 override def stripTypeVar (implicit ctx : Context ): Type =
35673571 derivedAnnotatedType(tpe.stripTypeVar, annot)
3572+
35683573 override def stripAnnots (implicit ctx : Context ): Type = tpe.stripAnnots
35693574 }
35703575
@@ -3965,7 +3970,7 @@ object Types {
39653970 */
39663971 def tryWiden (tp : NamedType , pre : Type ): Type = pre.member(tp.name) match {
39673972 case d : SingleDenotation =>
3968- d.info match {
3973+ d.info.dealias match {
39693974 case TypeAlias (alias) =>
39703975 // if H#T = U, then for any x in L..H, x.T =:= U,
39713976 // hence we can replace with U under all variances
0 commit comments