scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

feat: [SemanticDB] support LambdaType (convert from HKTypeLambda)

Open tanishiking opened this issue 3 years ago • 1 comments

based on the new semanticdb schema https://github.com/scalameta/scalameta/pull/2867 https://github.com/tanishiking/semanticdb-for-scala3/commit/3981424f2eee9b03e6114b21026572f877185638

This commit adds support for LambdaType that is converted from HKTypeLambda in Scala3.

For example, the following type signature [A, B] =>> [C] =>> A | B | C

will be

LambdaType(
  parameters = Some(
    value = Scope(hardlinks =
      List(
        "....Union#[A]"
        "....Union#[B]"
      ), symlinks = List()
    )
  ),
  returnType = LambdaType(
    parameters = Some(
      value = Scope(hardlinks = List("....Union#[C]"), symlinks = List())
    ),
    returnType = UnionType(
      types = List(
        TypeRef(
          prefix = Empty,
          symbol = "....Union#[A]",
          typeArguments = List()
        ),
        TypeRef(
          prefix = Empty,
          symbol = "....Union#[B]",
          typeArguments = List()
        ),
        TypeRef(
          prefix = Empty,
          symbol = "....Union#[C]",
          typeArguments = List()
        )
      )
    )
  )
)

I'm wondering...

Previously, we embed type Id = [A] =>> A which is equivalent to type Id[A] = A https://github.com/lampepfl/dotty/blob/afc6ce4d2135e3532bf28146a7700d2cc4338e90/compiler/src/dotty/tools/dotc/semanticdb/TypeOps.scala#L218-L231 because we didn't have a way to express [A] =>> A in SemanticDB.

Now we support LambdaType in SemanticDB, maybe we can save type Id[A] = A as type Id = [A] =>> A instead of converting it to type Id[A] = A when converting the signature into SemanticDB. 🤔

tanishiking avatar Sep 16 '22 12:09 tanishiking

looks good!

bishabosha avatar Sep 16 '22 14:09 bishabosha

I'm not sure what happened here, sorry! but now it needs another rebase

bishabosha avatar Mar 27 '23 07:03 bishabosha

Hey, I rebased on the latest main 👍

tanishiking avatar Apr 14 '23 05:04 tanishiking

seems like tests/neg-custom-args/fatal-warnings/i15503g.scala is now failing the tests with some unused parameters warnings

bishabosha avatar Apr 14 '23 10:04 bishabosha