Skip to content

Commit da97bfb

Browse files
committed
Merge pull request #957 from dotty-staging/fix-#938
Fix #938
2 parents 57d05d3 + 3ec504c commit da97bfb

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

src/dotty/tools/dotc/core/Phases.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import dotty.tools.backend.jvm.{LabelDefs, GenBCode}
77
import util.DotClass
88
import DenotTransformers._
99
import Denotations._
10+
import Decorators._
1011
import config.Printers._
1112
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
1213
import dotty.tools.dotc.transform.TreeTransforms.{TreeTransformer, MiniPhase, TreeTransform}
@@ -121,10 +122,9 @@ object Phases {
121122
phase
122123
}
123124
squashedPhases += phaseToAdd
124-
val shouldAddYCheck = YCheckAfter.exists(nm => phaseToAdd.phaseName.contains(nm)) || YCheckAll
125+
val shouldAddYCheck = YCheckAfter.containsPhase(phaseToAdd) || YCheckAll
125126
if (shouldAddYCheck) {
126127
val checker = new TreeChecker
127-
128128
squashedPhases += checker
129129
}
130130
}

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
488488
case _ => tp2 isRef ObjectClass
489489
}
490490
compareJavaArray
491+
case tp1: ExprType if ctx.phase.id > ctx.gettersPhase.id =>
492+
// getters might have converted T to => T, need to compensate.
493+
isSubType(tp1.widenExpr, tp2)
491494
case _ =>
492495
false
493496
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ trait TypeAssigner {
4646
// TODO: measure the cost of using `existsPart`, and if necessary replace it
4747
// by a `TypeAccumulator` where we have set `stopAtStatic = true`.
4848
tp existsPart {
49-
case tp: NamedType =>
50-
forbidden contains tp.symbol
51-
case _ =>
52-
false
49+
case tp: NamedType => forbidden contains tp.symbol
50+
case tp: ThisType => forbidden contains tp.cls
51+
case _ => false
5352
}
5453
def apply(tp: Type): Type = tp match {
5554
case tp: TermRef if toAvoid(tp) && variance > 0 =>

test/dotc/scala-collections.whitelist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
./scala-scala/src/library/scala/collection/SortedSetLike.scala
187187
./scala-scala/src/library/scala/collection/Traversable.scala
188188

189-
# https://github.com/lampepfl/dotty/issues/938
189+
# https://github.com/lampepfl/dotty/issues/938 (but relies also on #937 being fixed)
190190
#./scala-scala/src/library/scala/collection/TraversableLike.scala
191191

192192
./scala-scala/src/library/scala/collection/TraversableProxy.scala

tests/pos/i938.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
object Test {
2+
import scala.collection._
3+
4+
trait T {
5+
def f() : Unit
6+
}
7+
8+
def view = new T {
9+
def f() = ()
10+
}
11+
12+
trait TLike[+A, RR] { self =>
13+
14+
def repr: RR = ???
15+
16+
def view2 = new TraversableView[A, RR] {
17+
protected lazy val underlying = self.repr
18+
override def foreach[U](f: A => U): Unit = ???
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)