Skip to content

Commit c896a83

Browse files
committed
Refinement for knownHK for PolyParams
pos test t2082.scala shows that knownHK can be constructed before the binder PolyType of a PolyParam is initialized.
1 parent 7dc3135 commit c896a83

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ class TypeApplications(val self: Type) extends AnyVal {
494494
case self: SingletonType => -1
495495
case self: TypeVar => self.origin.knownHK
496496
case self: WildcardType => self.optBounds.knownHK
497+
case self: PolyParam => self.underlying.knownHK
497498
case self: TypeProxy => self.underlying.knownHK
499+
case NoType => 0
498500
case _ => -1
499501
}
500502

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,11 @@ object Types {
27652765

27662766
def paramName = binder.paramNames(paramNum)
27672767

2768-
override def underlying(implicit ctx: Context): Type = binder.paramBounds(paramNum)
2768+
override def underlying(implicit ctx: Context): Type = {
2769+
val bounds = binder.paramBounds
2770+
if (bounds == null) NoType // this can happen if the PolyType is not initialized yet
2771+
else bounds(paramNum)
2772+
}
27692773
// no customized hashCode/equals needed because cycle is broken in PolyType
27702774
override def toString = s"PolyParam($paramName)"
27712775

0 commit comments

Comments
 (0)