Skip to content

Commit 1d83d0f

Browse files
authored
Merge pull request #12612 from dotty-staging/fix-12606
Typecheck imports with import symbol as owner
2 parents 5340d89 + 71fb5ad commit 1d83d0f

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
@@ -2457,7 +2457,7 @@ class Typer extends Namer
24572457
else typd(imp.expr, AnySelectionProto)
24582458

24592459
def typedImport(imp: untpd.Import, sym: Symbol)(using Context): Import =
2460-
val expr1 = typedImportQualifier(imp, typedExpr)
2460+
val expr1 = typedImportQualifier(imp, typedExpr(_, _)(using ctx.withOwner(sym)))
24612461
checkLegalImportPath(expr1)
24622462
val selectors1 = typedSelectors(imp.selectors)
24632463
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)