Skip to content

Commit 4d12135

Browse files
committed
Fix checking for disabled root imports
Needs to be done always when hitting a wildcard import, not just when something was found
1 parent e9d1319 commit 4d12135

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ class Typer extends Namer with Applications with Implicits {
283283
* from given import info
284284
*/
285285
def wildImportRef(imp: ImportInfo): Type = {
286-
if (imp.isWildcardImport && !(imp.excluded contains name.toTermName)) {
286+
if (imp.isWildcardImport) {
287287
val pre = imp.site
288-
if (!isDisabled(imp, pre)) {
288+
if (!isDisabled(imp, pre) && !(imp.excluded contains name.toTermName)) {
289289
val denot = pre.member(name)
290290
if (reallyExists(denot)) return pre.select(name, denot)
291291
}
@@ -1024,7 +1024,7 @@ class Typer extends Namer with Applications with Implicits {
10241024
}
10251025
}
10261026

1027-
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = ctx.traceIndented (s"typing ${tree.show}", typr, show = true) {
1027+
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ ctx.traceIndented (s"typing ${tree.show}", typr, show = true) /*<|<*/ {
10281028
if (!tree.isEmpty && ctx.typerState.isGlobalCommittable) assert(tree.pos.exists, tree)
10291029
try adapt(typedUnadapted(tree, pt), pt)
10301030
catch {
@@ -1090,8 +1090,8 @@ class Typer extends Namer with Applications with Implicits {
10901090
fallBack
10911091
}
10921092

1093-
def adapt(tree: Tree, pt: Type)(implicit ctx: Context) = track("adapt") {
1094-
ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) {
1093+
def adapt(tree: Tree, pt: Type)(implicit ctx: Context) = /*>|>*/ track("adapt") /*<|<*/ {
1094+
/*>|>*/ ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ {
10951095
interpolateUndetVars(tree)
10961096
tree overwriteType tree.tpe.simplified
10971097
adaptInterpolated(tree, pt)

tests/neg/rootImplicits.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package test
2+
3+
import dotty._
4+
import Predef.{any2stringadd => _, _}
5+
6+
object rootImplicits {
7+
8+
println((new Object()) + "abc") // error: `+` is not member of Object
9+
println(any2stringadd(new Object()) + "abc") // error: not found: any2stringadd
10+
11+
}

0 commit comments

Comments
 (0)