Skip to content

[Backport] Fix regressions in asSeenFrom introduced in 3.7 #23442

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: release-3.7.2
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ object TypeOps:
}

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

/** Implementation of Types#simplified */
def simplify(tp: Type, theMap: SimplifyMap | Null)(using Context): Type = {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/lazylist.check
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/lazylist.scala:41:42 -------------------------------------
41 | val ref4c: LazyList[Int]^{cap1, ref3} = ref4 // error
| ^^^^
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, ref1, ref2})
| Found: (ref4 : lazylists.LazyList[Int]^{cap3, cap1, cap2})
| Required: lazylists.LazyList[Int]^{cap1, ref3}
|
| longer explanation available when compiling with `-explain`
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/6314-6.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
|object creation impossible, since def apply(fa: String): Int in trait XX in object Test3 is not defined
|(Note that
| parameter String in def apply(fa: String): Int in trait XX in object Test3 does not match
| parameter Test3.Bar[X & (X & Y)] in def apply(fa: Test3.Bar[X & YY.this.Foo]): Test3.Bar[Y & YY.this.Foo] in trait YY in object Test3
| parameter Test3.Bar[X & Object with Test3.YY {...}#Foo] in def apply(fa: Test3.Bar[X & YY.this.Foo]): Test3.Bar[Y & YY.this.Foo] in trait YY in object Test3
| )
-- Error: tests/neg/6314-6.scala:52:3 ----------------------------------------------------------------------------------
52 | (new YY {}).boom // error: object creation impossible
| ^
|object creation impossible, since def apply(fa: String): Int in trait XX in object Test4 is not defined
|(Note that
| parameter String in def apply(fa: String): Int in trait XX in object Test4 does not match
| parameter Test4.Bar[X & (X & Y)] in def apply(fa: Test4.Bar[X & YY.this.FooAlias]): Test4.Bar[Y & YY.this.FooAlias] in trait YY in object Test4
| parameter Test4.Bar[X & Object with Test4.YY {...}#FooAlias] in def apply(fa: Test4.Bar[X & YY.this.FooAlias]): Test4.Bar[Y & YY.this.FooAlias] in trait YY in object Test4
| )
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

11 changes: 11 additions & 0 deletions tests/pos/i22676.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package example

trait Example {
class Input

type Output[A] = A match {
case Input => Int
}
}

class Ref(ref: Example#Input)
Loading