diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index f421c75f9287..7893114b86d9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -703,7 +703,7 @@ class Namer { typer: Typer => typer1.defDefSig(original, sym)(using localContext(sym).setTyper(typer1)) case imp: Import => try - val expr1 = typedImportQualifier(imp, typedAheadExpr) + val expr1 = typedImportQualifier(imp, typedAheadExpr(_, _)(using ctx.withOwner(sym))) ImportType(expr1) catch case ex: CyclicReference => typr.println(s"error while completing ${imp.expr}") diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index cda1daafd252..184dfac6537b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2450,7 +2450,7 @@ class Typer extends Namer else typd(imp.expr, AnySelectionProto) def typedImport(imp: untpd.Import, sym: Symbol)(using Context): Import = - val expr1 = typedImportQualifier(imp, typedExpr) + val expr1 = typedImportQualifier(imp, typedExpr(_, _)(using ctx.withOwner(sym))) checkLegalImportPath(expr1) val selectors1 = typedSelectors(imp.selectors) assignType(cpy.Import(imp)(expr1, selectors1), sym) diff --git a/tests/neg/i12606.scala b/tests/neg/i12606.scala new file mode 100644 index 000000000000..53f88387af36 --- /dev/null +++ b/tests/neg/i12606.scala @@ -0,0 +1,8 @@ +import scala.quoted._ + +trait ReflectModule { + implicit def q: Quotes + import quotes.reflect._ // error + + def foo(x: TypeRepr): Unit = ??? +} \ No newline at end of file