Skip to content

Fix quote re-typing error #23425

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ object TypeOps:
}

def isLegalPrefix(pre: Type)(using Context): Boolean =
// This used to be `pre.isStable || !ctx.phase.isTyper` but the latter
// condition was dropped in #21954 to make implicit search during the
// inlining phase behave more like implicit search during the typer phase.
// However, this change has led to retyping issues (#23423) and I suspect
// other issues could crop up as we might end up calling asSeenFrom with a
// widened prefix in various situations post-typer.
pre.isStable

/** Implementation of Types#simplified */
Expand Down
14 changes: 8 additions & 6 deletions compiler/src/dotty/tools/dotc/staging/HealType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
*/
def apply(tp: Type): Type =
tp match
case NonSpliceAlias(aliased) => this.apply(aliased)
case tp: TypeRef => healTypeRef(tp)
case tp: TermRef =>
val inconsistentRoot = levelInconsistentRootOfPath(tp)
if inconsistentRoot.exists then levelError(inconsistentRoot, tp, pos)
else mapOver(tp)
case tp: NamedType if tp.symbol.isLocal => tp match
case NonSpliceAlias(aliased) =>
this.apply(aliased)
case tp: TypeRef => healTypeRef(tp)
case tp: TermRef =>
val inconsistentRoot = levelInconsistentRootOfPath(tp)
if inconsistentRoot.exists then levelError(inconsistentRoot, tp, pos)
else mapOver(tp)
case tp: AnnotatedType =>
derivedAnnotatedType(tp, apply(tp.parent), tp.annot)
case _ =>
Expand Down
16 changes: 16 additions & 0 deletions tests/pos-macros/i23423/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pkg

import scala.quoted.*

trait HasElem {
type Elem
type Alias = Elem
}

object Macro:
inline def foo: Unit = ${fooImpl}
def fooImpl(using Quotes): Expr[Unit] =
'{
val lll: (he: HasElem) => he.Alias =
(hx: HasElem) => ???
}
6 changes: 6 additions & 0 deletions tests/pos-macros/i23423/B_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test:
def test: Unit = pkg.Macro.foo
// used to be error:
// Found: (hx: pkg.HasElem) => hx.Elem
// Required: (he: pkg.HasElem) => he.Elem

Loading