Skip to content

Typecheck imports with import symbol as owner #12612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i12606.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.quoted._

trait ReflectModule {
implicit def q: Quotes
import quotes.reflect._ // error

def foo(x: TypeRepr): Unit = ???
}