Skip to content

Conversation

smarter
Copy link
Member

@smarter smarter commented Mar 11, 2023

Before this commit, one compiled but two didn't in:

class Foo[+T]
class Elem:
  def one(a: Elem, x: Foo[a.type]): Int = x.ext
  def two(x: Foo[Elem.this.type]): Int  = x.ext
object Elem:
  extension (x: Foo[Elem]) def ext: Int = 1

This happened because the anchors of the singleton reference a.type includes its underlying type Elem, but Elem.this.type has no anchors at all. This commit changes the definition of anchors to rectify this, which also brings us closer to how Scala 2 behaves.

Before this commit, `one` compiled but `two` didn't in:

    class Foo[+T]
    class Elem:
      def one(a: Elem, x: Foo[a.type]): Int = x.ext
      def two(x: Foo[Elem.this.type]): Int  = x.ext
    object Elem:
      extension (x: Foo[Elem]) def ext: Int = 1

This happened because the anchors of the singleton reference `a.type` includes
its underlying type `Elem`, but `Elem.this.type` has no anchors at all. This
commit changes the definition of anchors to rectify this, which also brings us
closer to how Scala 2 behaves.
@smarter smarter requested a review from odersky March 11, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants