Skip to content
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

Scala3: inferred type parameters shown twice #4372

Closed
unthingable opened this issue Sep 12, 2022 · 4 comments · Fixed by scala/scala3#16031
Closed

Scala3: inferred type parameters shown twice #4372

unthingable opened this issue Sep 12, 2022 · 4 comments · Fixed by scala/scala3#16031
Assignees
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket Scala 3 Generic ticket relating to Scala 3 semanticdb Related to semanticdb usage in Metals

Comments

@unthingable
Copy link

Describe the bug

image

Even though a parameter is explicitly specified, another [A] is shown.

A more complex example:

class SliderBankMode[Proxy, Param](
  override val id: String,
  val obj: Int => Proxy,
  val param: Proxy => Param,
  val barMode: Seq[BarMode],
  val stripColor: Option[Int => Int] = None,
)(using ext: MonsterJamExt, j: JamSurface, pValue: ParamValue[Param], exists: Exists[Proxy])
    extends SimpleModeLayer(id)

image

Vector type is displayed correctly, but new SliderBankMode has two sets of parameters.

Expected behavior

No response

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

0.11.18

Extra context or search terms

Scala 3.2.1-RC1

@tanishiking
Copy link
Member

@unthingable Thank you for reporting! Indeed it (after extends C1[A]) shouldn't be shown.

@tanishiking tanishiking added bug Something that is making a piece of functionality unusable Scala 3 Generic ticket relating to Scala 3 semanticdb Related to semanticdb usage in Metals labels Sep 12, 2022
tanishiking added a commit to tanishiking/scala3 that referenced this issue Sep 13, 2022
@tanishiking tanishiking self-assigned this Sep 13, 2022
@tanishiking
Copy link
Member

scala/scala3#16031 this PR should fix the problem :)

bishabosha added a commit to scala/scala3 that referenced this issue Sep 13, 2022
This PR fixes the regressions in SemanticDB's TypeApply synthetics
introduced by #15877

-
e835dc0
-
097b179
-
097b179

Previously, we relies on `Scala2` flag for filtering out some
synthetics, which isn't reliable for SemanticDB (that's why the capture
checking made a change in how the compiler put flags to symbols and the
regression occurred).
This PR fixes the regression by re-implements TypeApply synthetics
without using `Scala2` flag.

(also fix scalameta/metals#4372)

Probably, it makes more sense to compare the `metac.expect`'s diff from
53e1adc which was something before the
regression.

<details>
<summary>diff from 53e1adc</summary>

`git diff 53e1adc HEAD
tests/semanticdb/metac.expect`

```diff
diff --git a/tests/semanticdb/metac.expect b/tests/semanticdb/metac.expect
index 5e20650513..2c7f720937 100644
--- a/tests/semanticdb/metac.expect
+++ b/tests/semanticdb/metac.expect
@@ -50,7 +50,7 @@ Text => empty
 Language => Scala
 Symbols => 60 entries
 Occurrences => 132 entries
-Synthetics => 4 entries
+Synthetics => 3 entries
 
 Symbols:
 advanced/C# => class C [typeparam T ] extends Object { self: C[T] => +3 decls }
@@ -252,7 +252,6 @@ Synthetics:
 [27:12..27:16):s.s1 => reflectiveSelectable(*)
 [29:12..29:16):s.s2 => reflectiveSelectable(*)
 [31:12..31:16):s.s3 => reflectiveSelectable(*)
-[47:19..47:24):foo.a => *[foo.A]
 
 expect/Annotations.scala
 ------------------------
@@ -264,7 +263,6 @@ Text => empty
 Language => Scala
 Symbols => 23 entries
 Occurrences => 52 entries
-Synthetics => 2 entries
 
 Symbols:
 annot/Alias. => final object Alias extends Object { self: Alias.type => +2 decls }
@@ -345,10 +343,6 @@ Occurrences:
 [39:11..39:26): ClassAnnotation -> com/javacp/annot/ClassAnnotation#
 [39:28..39:33): param -> scala/annotation/meta/param#
 
-Synthetics:
-[25:2..25:20):@throws[Exception] => *[Exception]
-[25:2..25:20):@throws[Exception] => *[Exception]
-
 expect/Anonymous.scala
 ----------------------
 
@@ -896,7 +890,7 @@ Text => empty
 Language => Scala
 Symbols => 181 entries
 Occurrences => 148 entries
-Synthetics => 10 entries
+Synthetics => 6 entries
 
 Symbols:
 _empty_/Enums. => final object Enums extends Object { self: Enums.type => +30 decls }
@@ -1232,16 +1226,12 @@ Occurrences:
 [68:25..68:31): Planet -> _empty_/Enums.Planet#
 
 Synthetics:
-[46:28..46:35):C <:< C => *[C, C]
-[49:27..49:31):Refl => *.apply[T]
 [52:9..52:13):Refl => *.unapply[Option[B]]
-[52:19..52:30):opt.flatMap => *[B]
 [52:31..52:50):identity[Option[B]] => *[Function1[A, Option[B]]]
 [54:14..54:18):Some => *.apply[Some[Int]]
 [54:14..54:34):Some(Some(1)).unwrap => *(given_<:<_T_T[Option[Int]])
 [54:19..54:23):Some => *.apply[Int]
 [54:28..54:34):unwrap => *[Some[Int], Int]
-[56:52..56:64):Enum[Planet] => *[Planet]
 
 expect/EtaExpansion.scala
 -------------------------
@@ -3165,7 +3155,7 @@ Text => empty
 Language => Scala
 Symbols => 52 entries
 Occurrences => 132 entries
-Synthetics => 36 entries
+Synthetics => 39 entries
 
 Symbols:
 example/Synthetic# => class Synthetic extends Object { self: Synthetic => +23 decls }
@@ -3361,12 +3351,15 @@ Synthetics:
 [6:2..6:18):Array.empty[Int] => intArrayOps(*)
 [7:2..7:8):"fooo" => augmentString(*)
 [10:13..10:24):"name:(.*)" => augmentString(*)
+[11:8..11:11):#:: => *.unapply[Int]
 [11:17..11:25):LazyList => *.apply[Int]
 [13:4..13:28):#:: 2 #:: LazyList.empty => *[Int]
 [13:8..13:28):2 #:: LazyList.empty => toDeferrer[Int](*)
 [13:10..13:28):#:: LazyList.empty => *[Int]
 [13:14..13:28):LazyList.empty => toDeferrer[Nothing](*)
 [13:14..13:28):LazyList.empty => *[Nothing]
+[15:9..15:12):#:: => *.unapply[Int]
+[15:16..15:19):#:: => *.unapply[Int]
 [15:25..15:33):LazyList => *.apply[Int]
 [17:14..17:38):#:: 2 #:: LazyList.empty => *[Int]
 [17:18..17:38):2 #:: LazyList.empty => toDeferrer[Int](*)
@@ -3471,7 +3464,7 @@ Text => empty
 Language => Scala
 Symbols => 22 entries
 Occurrences => 46 entries
-Synthetics => 7 entries
+Synthetics => 11 entries
 
 Symbols:
 example/ValPattern# => class ValPattern extends Object { self: ValPattern => +14 decls }
@@ -3546,12 +3539,16 @@ Occurrences:
 [40:10..40:18): rightVar -> local4
 
 Synthetics:
+[5:6..5:10):Some => *.unapply[Int]
 [6:4..6:8):Some => *.apply[Int]
 [8:6..8:10):List => *.unapplySeq[Nothing]
 [8:11..8:15):Some => *.unapply[Nothing]
+[11:6..11:10):Some => *.unapply[Int]
 [12:4..12:8):Some => *.apply[Int]
 [25:4..25:11):locally => *[Unit]
+[27:10..27:14):Some => *.unapply[Int]
 [28:8..28:12):Some => *.apply[Int]
+[31:10..31:14):Some => *.unapply[Int]
 [32:8..32:12):Some => *.apply[Int]
 
 expect/Vals.scala
@@ -4264,7 +4261,6 @@ Text => empty
 Language => Scala
 Symbols => 36 entries
 Occurrences => 46 entries
-Synthetics => 3 entries
 
 Symbols:
 local0 => type N$1  <: Nat
@@ -4352,11 +4348,6 @@ Occurrences:
 [23:35..23:39): Zero -> recursion/Nats.Zero.
 [23:40..23:42): ++ -> recursion/Nats.Nat#`++`().
 
-Synthetics:
-[5:50..5:54):Succ => *.apply[Nat.this.type]
-[10:13..10:17):Succ => *.unapply[N$1]
-[20:11..20:15):Succ => *.unapply[N$2]
-
 expect/semanticdb-Definitions.scala
 -----------------------------------
 
```

</details>
@tanishiking tanishiking added the fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket label Sep 14, 2022
@tanishiking
Copy link
Member

3.2.1-RC2 (or 3.2.1) should fix the issue, let's close after confirming this is fixed in the next release version.

mpollmeier pushed a commit to mpollmeier/dotty that referenced this issue Oct 16, 2022
@tgodzik
Copy link
Contributor

tgodzik commented Nov 30, 2022

Looks like it might end up in 3.3.x, the recent nightlies seem to work ok.

@tgodzik tgodzik closed this as completed Nov 30, 2022
@tgodzik tgodzik added this to the Metals v0.11.10 milestone Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable fixed-upstream Tag a ticket with this when a fix upstream has been completed and we can now address the ticket Scala 3 Generic ticket relating to Scala 3 semanticdb Related to semanticdb usage in Metals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants