Skip to content

Commit a307ebd

Browse files
committed
Handle self types that are aliases of capturing types
1 parent e434e5f commit a307ebd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4999,9 +4999,9 @@ object Types {
49994999
if (!givenSelf.isValueType) appliedRef
50005000
else if (clsd.is(Module)) givenSelf
50015001
else if (ctx.erasedTypes) appliedRef
5002-
else givenSelf match
5003-
case givenSelf @ EventuallyCapturingType(tp, _) =>
5004-
givenSelf.derivedAnnotatedType(tp & appliedRef, givenSelf.annot)
5002+
else givenSelf.dealiasKeepAnnots match
5003+
case givenSelf1 @ EventuallyCapturingType(tp, _) =>
5004+
givenSelf1.derivedAnnotatedType(tp & appliedRef, givenSelf1.annot)
50055005
case _ =>
50065006
AndType(givenSelf, appliedRef)
50075007
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import language.experimental.captureChecking
2+
3+
type AnyIterableOnce[A] = IterableOnce[A]^
4+
5+
/** Iterator can be used only once */
6+
trait IterableOnce[+A]:
7+
//this: IterableOnce[A]{ref any} =>
8+
this: AnyIterableOnce[A] =>
9+
def iterator: Iterator[A]^{this}

0 commit comments

Comments
 (0)