Skip to content

Check that we don't leak uninstantiated type variables #4084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ class TreeChecker extends Phase with SymTransformer {
}

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