Skip to content

Commit e19eb07

Browse files
committed
Fix regressions in asSeenFrom introduced in 3.7
The body of this method used to read: pre.isStable || !ctx.phase.isTyper but was changed to drop the second condition in #21954 (originally included in 3.6.4-RC1, reverted from 3.6.4 final but back in 3.7). This has led to a number of regressions, the last ones discussed in #23423. To make the testcases added in #21594 pass, this PR proposes a less drastic change: relax isLegalPrefix as before, unless we're doing an implicit search. This should dramatically reduce the possibility for regressions.
1 parent d944b61 commit e19eb07

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ object TypeOps:
125125
}
126126

127127
def isLegalPrefix(pre: Type)(using Context): Boolean =
128-
pre.isStable
128+
// isLegalPrefix is relaxed after typer unless we're doing an implicit
129+
// search (this matters when doing summonInline in an inline def like in tests/pos/i17222.8.scala).
130+
pre.isStable || !ctx.phase.isTyper && ctx.mode.is(Mode.ImplicitsEnabled)
129131

130132
/** Implementation of Types#simplified */
131133
def simplify(tp: Type, theMap: SimplifyMap | Null)(using Context): Type = {

tests/pos-macros/i23423/A_1.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package pkg
2+
3+
import scala.quoted.*
4+
5+
trait HasElem {
6+
type Elem
7+
type Alias = Elem
8+
}
9+
10+
object Macro:
11+
inline def foo: Unit = ${fooImpl}
12+
def fooImpl(using Quotes): Expr[Unit] =
13+
'{
14+
val lll: (he: HasElem) => he.Alias =
15+
(hx: HasElem) => ???
16+
}

tests/pos-macros/i23423/B_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test:
2+
def test: Unit = pkg.Macro.foo
3+
// used to be error:
4+
// Found: (hx: pkg.HasElem) => hx.Elem
5+
// Required: (he: pkg.HasElem) => he.Elem
6+

0 commit comments

Comments
 (0)