scalacenter / tasty-query

Apache License 2.0
52 stars 11 forks source link

Thoughts on TASTy grammar #27

Open cache-nez opened 3 years ago

cache-nez commented 3 years ago

This is the list of my impressions from working with the TASTy grammar, which can hopefully be useful for an eventual discussion of TASTy. Additions are welcome.

sjrd commented 2 years ago

New thing: DefDefs don't have a SignedName at definition site. It needs to be recomputed from the erasure, which requires dereferencing all the types in the signautre.

sjrd commented 1 year ago

TermRefs for private (and even local like non-val constructor param) members should always be TERMREFsymbols, so that name-based field selection can systematically filter out Private and be done with it. private members are never accessible from another .tasty file, so we always have access to the symbol.

sjrd commented 1 year ago

SuperTypes should not exist at all. They may have had a reason to exist when it was possible to shadow an inherited class with another class, but that is not allowed in Scala 3 anymore.

Super nodes should not exist as a dedicated thing. They should be fused with their enclosing Select as SuperSelect, and be reserved to term selection.

sjrd commented 11 months ago

https://github.com/lampepfl/dotty/issues/19307

The param of AnyVal classes should never have the LOCAL flag, because it gets automatically accessed on another instance in the generated equals method. Example:

class ValueClassNonVal(self: String) extends AnyVal:
  def get: String = self // TERMREFsymbol, OK
  def getThroughThis: String = this.self // SELECT, ~OK because this prefix

  // def getOther(that: ValueClassNonVal): String = that.self // does not compile, rightly so

  // <generated>
  def equals(x$0: Any): Boolean = x$0 match
    case x$0: ValueClassNonVal =>
      this.self // SELECT, ~OK because this prefix
        == x$0.self // SELECT, definitely not OK
    case _ =>
      false
end ValueClassNonVal