-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the unwidened type when casting structural calls (#18527)
So if the call is to a stable val, the call will have a stable type.
- Loading branch information
Showing
5 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
sealed trait Scope | ||
sealed trait Domain extends Scope | ||
object Domain extends Domain | ||
|
||
trait Baz[T] | ||
def baz(using ck: Scope): Baz[ck.type] = ??? | ||
|
||
class Foo extends scala.reflect.Selectable: | ||
type TScope = Domain | ||
final protected given TScope = Domain | ||
|
||
object ID: | ||
val internal1 = new Foo: | ||
val ii = new Foo: | ||
val x = baz | ||
val z = internal1.ii.x //error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
final class Bar | ||
final class Inv[T] | ||
class Foo extends scala.reflect.Selectable: | ||
type Boo = Bar | ||
final given boo1: Boo = new Bar | ||
|
||
class Test: | ||
def mkInv(using bar: Bar): Inv[bar.type] = new Inv() | ||
|
||
def test: Unit = | ||
val foo1 /* : Foo { val foo2: { z1 => Foo { val inv1: Inv[(z1.boo1 : z1.Boo)] }}} */ = new Foo: | ||
val foo2 /* : { z1 => Foo { val inv1: Inv[(z1.boo1 : z1.Boo)] }} */ = new Foo: | ||
val inv1 /* : Inv[( boo1 : Boo)] */ = mkInv /* (this.boo1) */ | ||
val inv2 = foo1.foo2.inv1 // error | ||
() |