File tree 5 files changed +18
-7
lines changed
src/dotty/tools/dotc/typer 5 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -138,20 +138,20 @@ object Checking {
138
138
case SuperType (thistp, _) => isInteresting(thistp)
139
139
case AndType (tp1, tp2) => isInteresting(tp1) || isInteresting(tp2)
140
140
case OrType (tp1, tp2) => isInteresting(tp1) && isInteresting(tp2)
141
- case _ : RefinedType => false
142
- // Note: it's important not to visit parents of RefinedTypes,
143
- // since otherwise spurious #Apply projections might be inserted.
141
+ case _ : RefinedType => true
144
142
case _ => false
145
143
}
146
144
// If prefix is interesting, check info of typeref recursively, marking the referred symbol
147
145
// with NoCompleter. This provokes a CyclicReference when the symbol
148
146
// is hit again. Without this precaution we could stackoverflow here.
149
147
if (isInteresting(pre)) {
150
148
val info = tp.info
151
- val symInfo = tp.symbol.info
152
- if (tp.symbol.exists) tp.symbol.info = SymDenotations .NoCompleter
149
+ val sym = tp.symbol
150
+ if (sym.infoOrCompleter == SymDenotations .NoCompleter ) throw CyclicReference (sym)
151
+ val symInfo = sym.info
152
+ if (sym.exists) sym.info = SymDenotations .NoCompleter
153
153
try checkInfo(info)
154
- finally if (tp.symbol. exists) tp.symbol .info = symInfo
154
+ finally if (sym. exists) sym .info = symInfo
155
155
}
156
156
tp
157
157
} catch {
Original file line number Diff line number Diff line change 266
266
./scala-scala/src/library/scala/collection/generic/ParFactory.scala
267
267
268
268
# https://github.com/lampepfl/dotty/issues/974 -> @smarter
269
- # ./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala
269
+ ./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala
270
270
271
271
# cyclic reference, maybe related to #974 -> @smarter
272
272
#./scala-scala/src/library/scala/collection/generic/ParSetFactory.scala
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ class tests extends CompilerTest {
158
158
@ Test def neg_finalSealed = compileFile(negDir, " final-sealed" , xerrors = 2 )
159
159
@ Test def neg_i705 = compileFile(negDir, " i705-inner-value-class" , xerrors = 7 )
160
160
@ Test def neg_i866 = compileFile(negDir, " i866" , xerrors = 2 )
161
+ @ Test def neg_i974 = compileFile(negDir, " i974" , xerrors = 2 )
161
162
@ Test def neg_moduleSubtyping = compileFile(negDir, " moduleSubtyping" , xerrors = 4 )
162
163
@ Test def neg_escapingRefs = compileFile(negDir, " escapingRefs" , xerrors = 2 )
163
164
@ Test def neg_instantiateAbstract = compileFile(negDir, " instantiateAbstract" , xerrors = 8 )
Original file line number Diff line number Diff line change
1
+ trait Foo [T <: Bar [T ]# Elem ] // error: illegal cyclic reference
2
+ trait Bar [T ] {
3
+ type Elem = T
4
+ }
5
+ trait Foo2 [T <: Bar2 [T ]# Elem ] // error: illegal cyclic reference
6
+ trait Bar2 [T ] {
7
+ type Elem = T
8
+ }
Original file line number Diff line number Diff line change
1
+ class Foo [A ]
2
+ class Bar [CC [X ] <: Foo [CC [X ]]]
You can’t perform that action at this time.
0 commit comments