Skip to content

Commit cef7d87

Browse files
committed
Address review
1 parent 705e50d commit cef7d87

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,10 +785,9 @@ trait Checking {
785785
|its constructor cannot be called again""", call.sourcePos)
786786

787787
if (caller.is(Module)) {
788-
val objRef = caller.sourceModule.termRef
789788
val traverser = new TreeTraverser {
790789
def traverse(tree: Tree)(implicit ctx: Context) = tree match {
791-
case tree: RefTree if tree.isTerm && tree.tpe <:< objRef =>
790+
case tree: RefTree if tree.isTerm && (tree.tpe.widen.classSymbol eq caller) =>
792791
ctx.error("super constructor cannot be passed a self reference", tree.sourcePos)
793792
case _ =>
794793
traverseChildren(tree)

tests/run/i4659b.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
case class SourcePosition(outer: SourcePosition = (NoSourcePosition: SourcePosition))
22

3+
// The code should not compile -- currently out of reach
34
object NoSourcePosition extends SourcePosition()
45

56
object Test extends App {

0 commit comments

Comments
 (0)