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

[SemanticDB] fix regression in type apply synthetics #16031

Merged
merged 2 commits into from Sep 13, 2022

Conversation

tanishiking
Copy link
Member

This PR fixes the regressions in SemanticDB's TypeApply synthetics introduced by #15877

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.

diff from 53e1adc

git diff 53e1adc783fbe1bdc0636b19c24244617cbb2552 HEAD tests/semanticdb/metac.expect

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
 -----------------------------------
 

Most of the type apply synthetics have disappeared in
scala#15877
because, previously we relies on the `Scala2` flag
for filtering out TypeApply synthetics.

However, it was hacky, and the capture checking PR
makes change on how the compiler put the flags to symbols.
As a result, most TypeApply synthetics have disappeared.

this commit revives those disappeared type apply synthetics.
@bishabosha
Copy link
Member

looks like a lot of better synthetics too

@bishabosha bishabosha merged commit 8c8eae9 into scala:main Sep 13, 2022
@tanishiking tanishiking deleted the revive-type-apply-synthetics branch September 14, 2022 02:24
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
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.

Scala3: inferred type parameters shown twice
3 participants