File tree Expand file tree Collapse file tree 4 files changed +31
-7
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -278,12 +278,17 @@ class Typer extends Namer
278278 // with the exact list of files given).
279279 val isNewDefScope =
280280 if (curOwner.is(Package ) && ! curOwner.isRoot) curOwner ne ctx.outer.owner
281- else ((ctx.scope ne lastCtx.scope) || (curOwner ne lastCtx.owner)) &&
282- ! curOwner.isPackageObject
283- // Package objects are never searched directly. We wait until we
284- // hit the enclosing package. That way we make sure we consider
285- // all overloaded alternatives of a definition, even if they are
286- // in different source files.
281+ else ((ctx.scope ne lastCtx.scope) || (curOwner ne lastCtx.owner))
282+ // Was: ... && !curOwner.isPackageObject
283+ // Package objects are never searched directly. We wait until we
284+ // hit the enclosing package. That way we make sure we consider
285+ // all overloaded alternatives of a definition, even if they are
286+ // in different source files.
287+ //
288+ // But this is now disabled since otherwise we will not see self type refinements
289+ // for opaque types.
290+ // We should evaluate later whether we want to keep & spec it that way,
291+ // or go back to the old scheme and compensate for opaque type refinements.
287292
288293 if (isNewDefScope) {
289294 val defDenot = ctx.denotNamed(name, required)
Original file line number Diff line number Diff line change 1+ package top
2+
3+ def hello (name : String ) = s " hello, $name"
4+ def hello (x : Int ) = x.toString
5+
6+ object O {
7+ def hi = hello(" Bob" )
8+ def gb = hello(true ) // OK
9+ }
10+
11+ val test1 = top.hello(false ) // OK, all overloaded variants are considered
12+
13+ val test2 = hello(false ) // error , since we now consider only local overloaded definitions
14+ // in the same compilation unit.
15+ // See comment on line 280 in Typer#findRef.
Original file line number Diff line number Diff line change 1+ package top
2+
3+ def hello (b : Boolean ): String = if (b) " yes" else " no"
4+
Original file line number Diff line number Diff line change @@ -9,4 +9,4 @@ object O {
99}
1010
1111val test1 = top.hello(false )
12- val test2 = hello(false )
12+ // val test2 = hello(false) // does not work anymore, see comment on line 280 in Typer#findRef.
You can’t perform that action at this time.
0 commit comments