Skip to content

Commit a147415

Browse files
authored
Merge pull request #476 from scala/backport-lts-3.3-23438
Backport "Fix regressions in asSeenFrom introduced in 3.7" to 3.3 LTS
2 parents 9506ac4 + a24216f commit a147415

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ object TypeOps:
123123
}
124124

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

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

tests/neg-custom-args/captures/lazylist.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
| Required: lazylists.LazyList[Int]^{cap2}
2727
|
2828
| longer explanation available when compiling with `-explain`
29-
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:41:48 -------------------------------------
30-
41 | val ref4c: LazyList[Int]^{cap1, ref3, cap3} = ref4 // error
31-
| ^^^^
32-
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap2, ref1, cap1})
33-
| Required: lazylists.LazyList[Int]^{cap1, ref3, cap3}
29+
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:41:42 -------------------------------------
30+
41 | val ref4c: LazyList[Int]^{cap1, ref3} = ref4 // error
31+
| ^^^^
32+
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap1, cap2})
33+
| Required: lazylists.LazyList[Int]^{cap1, ref3}
3434
|
3535
| longer explanation available when compiling with `-explain`
3636
-- [E164] Declaration Error: tests/neg-custom-args/captures/lazylist.scala:22:6 ----------------------------------------

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+

tests/pos/i22676.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package example
2+
3+
trait Example {
4+
class Input
5+
6+
type Output[A] = A match {
7+
case Input => Int
8+
}
9+
}
10+
11+
class Ref(ref: Example#Input)

0 commit comments

Comments
 (0)