Skip to content

Commit b01e17d

Browse files
committed
Add more explanations
1 parent ef8c11e commit b01e17d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ trait TypeAssigner {
350350
else {
351351
// Make sure arguments don't contain the type `pt` itself.
352352
// make a copy of the argument if that's the case.
353-
// See pos/i6682a.scala for a test case where this matters.
353+
// This is done to compensate for the fact that normally every
354+
// reference to a polytype would have to be a fresh copy of that type,
355+
// but we want to avoid that because it would increase compilation cost.
356+
// See pos/i6682a.scala for a test case where the defensive copying matters.
354357
val ensureFresh = new TypeMap:
355358
def apply(tp: Type) = mapOver(
356359
if tp eq pt then pt.newLikeThis(pt.paramNames, pt.paramInfos, pt.resType)

0 commit comments

Comments
 (0)