Skip to content

Commit 8f069b0

Browse files
authored
Merge pull request #4084 from dotty-staging/check-tvar-instantiation
Check that we don't leak uninstantiated type variables
2 parents becf98a + c3a3ec2 commit 8f069b0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,9 @@ class TreeChecker extends Phase with SymTransformer {
475475
}
476476

477477
object TreeChecker {
478-
/** Check that TypeParamRefs and MethodParams refer to an enclosing type */
478+
/** - Check that TypeParamRefs and MethodParams refer to an enclosing type.
479+
* - Check that all type variables are instantiated.
480+
*/
479481
def checkNoOrphans(tp0: Type, tree: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context) = new TypeMap() {
480482
val definedBinders = new java.util.IdentityHashMap[Type, Any]
481483
def apply(tp: Type): Type = {
@@ -487,6 +489,7 @@ object TreeChecker {
487489
case tp: ParamRef =>
488490
assert(definedBinders.get(tp.binder) != null, s"orphan param: ${tp.show}, hash of binder = ${System.identityHashCode(tp.binder)}, tree = ${tree.show}, type = $tp0")
489491
case tp: TypeVar =>
492+
assert(tp.isInstantiated, s"Uninstantiated type variable: ${tp.show}, tree = ${tree.show}")
490493
apply(tp.underlying)
491494
case _ =>
492495
mapOver(tp)

0 commit comments

Comments
 (0)