Skip to content

Commit f43af58

Browse files
authored
Merge pull request #8088 from dotty-staging/fix-#8064
Fix #8064: Do not cross cast constructors
2 parents 3a6d0c2 + 5b9d448 commit f43af58

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/transform/CrossCastAnd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CrossCastAnd extends MiniPhase {
2222

2323
lazy val qtype = tree.qualifier.tpe.widen
2424
val sym = tree.symbol
25-
if (sym.is(Flags.Private) && qtype.typeSymbol != sym.owner)
25+
if (sym.is(Flags.Private) && !sym.isConstructor && qtype.typeSymbol != sym.owner)
2626
cpy.Select(tree)(tree.qualifier.cast(AndType(qtype.baseType(sym.owner), tree.qualifier.tpe)), tree.name)
2727
else tree
2828
}

tests/run/i8064.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
class Foo[A] private(x: Int) { self => def this() = this(0) }
3+
4+
@main def Test = new Foo[String]()

0 commit comments

Comments
 (0)