From e3286bb8717370c9a9a2d4ba1278dc3ead44aa36 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 25 Jun 2019 23:14:04 +0200 Subject: [PATCH] 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. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 8 ++------ tests/pos/i5636.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 tests/pos/i5636.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 547f132d2066..7de0a03d0134 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -300,13 +300,9 @@ class Typer extends Namer if (isSelfDenot(defDenot)) curOwner.enclosingClass.thisType else { val effectiveOwner = - if (curOwner.isTerm && defDenot.symbol.isType) + if (curOwner.isTerm && defDenot.symbol.maybeOwner.isType) // Don't mix NoPrefix and thisType prefixes, since type comparer - // would not detect types to be compatible. Note: If we replace the - // 2nd condition by `defDenot.symbol.maybeOwner.isType` we get lots - // of failures in the `tastyBootstrap` test. Trying to compile these - // files in isolation works though. - // TODO: Investigate why that happens. + // would not detect types to be compatible. defDenot.symbol.owner else curOwner diff --git a/tests/pos/i5636.scala b/tests/pos/i5636.scala new file mode 100644 index 000000000000..0a38439d718e --- /dev/null +++ b/tests/pos/i5636.scala @@ -0,0 +1,9 @@ +class A +trait Bar[X] { + // same for `val foo: X = ???` + def foo: X = ??? +} +// same for `class Foo(...)...` +trait Foo(val a: A) extends Bar[a.type] { + val same: a.type = foo +}