Skip to content

Commit 71fb5ad

Browse files
committed
Typecheck imports with import symbol as owner
Fixes #12606 This broke before since the inliner is not prepared to operate with a class as owner.
1 parent 89e57aa commit 71fb5ad

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ class Namer { typer: Typer =>
703703
typer1.defDefSig(original, sym)(using localContext(sym).setTyper(typer1))
704704
case imp: Import =>
705705
try
706-
val expr1 = typedImportQualifier(imp, typedAheadExpr)
706+
val expr1 = typedImportQualifier(imp, typedAheadExpr(_, _)(using ctx.withOwner(sym)))
707707
ImportType(expr1)
708708
catch case ex: CyclicReference =>
709709
typr.println(s"error while completing ${imp.expr}")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,7 @@ class Typer extends Namer
24502450
else typd(imp.expr, AnySelectionProto)
24512451

24522452
def typedImport(imp: untpd.Import, sym: Symbol)(using Context): Import =
2453-
val expr1 = typedImportQualifier(imp, typedExpr)
2453+
val expr1 = typedImportQualifier(imp, typedExpr(_, _)(using ctx.withOwner(sym)))
24542454
checkLegalImportPath(expr1)
24552455
val selectors1 = typedSelectors(imp.selectors)
24562456
assignType(cpy.Import(imp)(expr1, selectors1), sym)

tests/neg/i12606.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted._
2+
3+
trait ReflectModule {
4+
implicit def q: Quotes
5+
import quotes.reflect._ // error
6+
7+
def foo(x: TypeRepr): Unit = ???
8+
}

0 commit comments

Comments
 (0)