Skip to content

Commit 8683f66

Browse files
committed
Refine determination of prefix in typedIdent
1 parent 60c7cac commit 8683f66

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,20 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
268268
if (qualifies(defDenot)) {
269269
val found =
270270
if (isSelfDenot(defDenot)) curOwner.enclosingClass.thisType
271-
else curOwner.thisType.select(name, defDenot)
271+
else {
272+
val effectiveOwner =
273+
if (curOwner.isTerm && defDenot.symbol.isType)
274+
// Don't mix NoPrefix and thisType prefixes, since type comparer
275+
// would not detect types to be compatible. Note: If we replace the
276+
// 2nd condition by `defDenot.symbol.maybeOwner.isType` we get lots
277+
// of failures in the `tastyBootstrap` test. Trying to compile these
278+
// files in isolation works though.
279+
// TODO: Investigate why that happens.
280+
defDenot.symbol.owner
281+
else
282+
curOwner
283+
effectiveOwner.thisType.select(name, defDenot)
284+
}
272285
if (!(curOwner is Package) || isDefinedInCurrentUnit(defDenot))
273286
result = checkNewOrShadowed(found, definition) // no need to go further out, we found highest prec entry
274287
else {

0 commit comments

Comments
 (0)