Skip to content

Commit 852a497

Browse files
smarterolsdavis
authored andcommitted
Fix crash on uninstantiated field access
The uninstantiated access in the test case happens because the closure passed to the HKTypeLambda constructor to construct the result type by `HKTypeLambda.newLikeThis` calls `subst` which eventually calls `HKTypeLambda#equals`, I don't see a way to prevent that at the source, so make equality checking robust to uninstantatied fields. Fixes scala#13513.
1 parent 1b7382b commit 852a497

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,6 +3876,8 @@ object Types {
38763876
x.declaredVariance == y.declaredVariance))
38773877
&& {
38783878
val bs1 = new BinderPairs(this, that, bs)
3879+
// `paramInfos` and `resType` might still be uninstantiated at this point
3880+
paramInfos != null && resType != null &&
38793881
paramInfos.equalElements(that.paramInfos, bs1) &&
38803882
resType.equals(that.resType, bs1)
38813883
}

tests/neg/i13513.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
final case class TwoTypes[F, A](value: A)
2+
class Minimal {
3+
def x[C[_]]: C[Int] = ???
4+
x[TwoTypes].value // error: Type argument TwoTypes does not conform to upper bound [_] =>> Any
5+
}

0 commit comments

Comments
 (0)