Skip to content

Commit e3286bb

Browse files
committed
Fix #5636: properly type param accessors in constructors
Replace the condition as suggested in the comment, the referenced test failures do not seem to happen anymore.
1 parent b8ed0df commit e3286bb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,9 @@ class Typer extends Namer
300300
if (isSelfDenot(defDenot)) curOwner.enclosingClass.thisType
301301
else {
302302
val effectiveOwner =
303-
if (curOwner.isTerm && defDenot.symbol.isType)
303+
if (curOwner.isTerm && defDenot.symbol.maybeOwner.isType)
304304
// Don't mix NoPrefix and thisType prefixes, since type comparer
305-
// would not detect types to be compatible. Note: If we replace the
306-
// 2nd condition by `defDenot.symbol.maybeOwner.isType` we get lots
307-
// of failures in the `tastyBootstrap` test. Trying to compile these
308-
// files in isolation works though.
309-
// TODO: Investigate why that happens.
305+
// would not detect types to be compatible.
310306
defDenot.symbol.owner
311307
else
312308
curOwner

tests/pos/i5636.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class A
2+
trait Bar[X] {
3+
// same for `val foo: X = ???`
4+
def foo: X = ???
5+
}
6+
// same for `class Foo(...)...`
7+
trait Foo(val a: A) extends Bar[a.type] {
8+
val same: a.type = foo
9+
}

0 commit comments

Comments
 (0)