Skip to content

Commit c6685d5

Browse files
committed
Better fix
`superType` should never return a `TypeBounds` in the first place. This commit makes sure it doesn't.
1 parent ebc3162 commit c6685d5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
239239
case tp1: RecType =>
240240
tp1.rebind(approximateOr(tp1.parent, tp2))
241241
case tp1: TypeProxy if !isClassRef(tp1) =>
242-
orDominator(tp1.superType.bounds.hi | tp2)
242+
orDominator(tp1.superType | tp2)
243243
case _ =>
244244
tp2 match {
245245
case tp2: RecType =>

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,10 @@ object Types {
12761276
* except for TypeRefs where the upper bound is returned, and HKApplys,
12771277
* where the upper bound of the constructor is re-applied to the arguments.
12781278
*/
1279-
def superType(implicit ctx: Context): Type = underlying
1279+
def superType(implicit ctx: Context): Type = underlying match {
1280+
case TypeBounds(_, hi) => hi
1281+
case st => st
1282+
}
12801283
}
12811284

12821285
// Every type has to inherit one of the following four abstract type classes.,
@@ -1762,11 +1765,6 @@ object Types {
17621765
type ThisType = TypeRef
17631766

17641767
override def underlying(implicit ctx: Context): Type = info
1765-
1766-
override def superType(implicit ctx: Context): Type = info match {
1767-
case TypeBounds(_, hi) => hi
1768-
case _ => info
1769-
}
17701768
}
17711769

17721770
final class TermRefWithSignature(prefix: Type, name: TermName, override val sig: Signature) extends TermRef(prefix, name) {

0 commit comments

Comments
 (0)