Skip to content

Commit aef23bc

Browse files
committed
Revert invented givens and anonymous using params for the time being
We have a discussion how to express the invented variable names in SemanticDB. We'll discuss the design of the tree in the issue and come back in the future.
1 parent fd67b6e commit aef23bc

File tree

4 files changed

+5
-35
lines changed

4 files changed

+5
-35
lines changed

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,11 @@ class ExtractSemanticDB extends Phase:
156156
case tree: DefDef if tree.symbol.isConstructor => // ignore typeparams for secondary ctors
157157
tree.trailingParamss.foreach(_.foreach(traverse))
158158
traverse(tree.rhs)
159-
case tree: (DefDef | ValDef) if tree.symbol.isSyntheticWithIdent || isInventedGiven(tree) =>
159+
case tree: (DefDef | ValDef) if tree.symbol.isSyntheticWithIdent =>
160160
tree match
161161
case tree: DefDef =>
162162
tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol)))
163163
case tree: ValDef if tree.symbol.is(Given) =>
164-
synth.tryFindSynthetic(tree).foreach(synthetics.addOne)
165164
traverse(tree.tpt)
166165
case _ =>
167166
if !tree.symbol.isGlobal then

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -514,16 +514,4 @@ object Scala3:
514514

515515
end IdentifierOrdering
516516

517-
/** Check if the symbol is invented by Desugar.inventGivenOrExtensionName
518-
* return true if the symbol is defined as `given Int = ...` and name is invented as "given_Int"
519-
*/
520-
def isInventedGiven(tree: tpd.Tree)(using Context): Boolean =
521-
tree match
522-
case tree: tpd.ValDef =>
523-
val sym = tree.symbol
524-
sym.is(Given) &&
525-
sym.name.startsWith("given_") &&
526-
!namePresentInSource(sym, tree.nameSpan, tree.source)
527-
case _ => false
528-
529517
end Scala3

compiler/src/dotty/tools/dotc/semanticdb/SyntheticsExtractor.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SyntheticsExtractor:
1515
extension (synth: s.Synthetic)
1616
def toOpt: Some[s.Synthetic] = Some(synth)
1717

18-
if tree.span.isSynthetic || isInventedGiven(tree) then
18+
if tree.span.isSynthetic then
1919
tree match
2020
case tree: Apply if isForSynthetic(tree) =>
2121
None // not yet supported (for synthetics)
@@ -45,12 +45,6 @@ class SyntheticsExtractor:
4545
)
4646
).toOpt
4747

48-
// Anonymous context parameter
49-
case tree: ValDef if tree.symbol.is(Given) =>
50-
s.Synthetic(
51-
range(tree.span, tree.source),
52-
tree.toSemanticId
53-
).toOpt
5448
case _ => None
5549
else None
5650

tests/semanticdb/metac.expect

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ Text => empty
368368
Language => Scala
369369
Symbols => 5 entries
370370
Occurrences => 4 entries
371-
Synthetics => 1 entries
372371

373372
Symbols:
374373
angiven/AnonymousGiven$package. => final package object angiven extends Object { self: angiven.type => +2 decls }
@@ -383,9 +382,6 @@ Occurrences:
383382
[4:4..4:7): bar <- angiven/AnonymousGiven$package.bar().
384383
[4:14..4:17): Foo -> angiven/Foo#
385384

386-
Synthetics:
387-
[4:14..4:17):Foo => x$1
388-
389385
expect/Classes.scala
390386
--------------------
391387

@@ -1238,7 +1234,7 @@ Text => empty
12381234
Language => Scala
12391235
Symbols => 26 entries
12401236
Occurrences => 50 entries
1241-
Synthetics => 2 entries
1237+
Synthetics => 1 entries
12421238

12431239
Symbols:
12441240
ext/Extension$package. => final package object ext extends Object { self: ext.type => +6 decls }
@@ -1321,7 +1317,6 @@ Occurrences:
13211317
[17:50..17:51): U -> ext/Functor#map().[U]
13221318

13231319
Synthetics:
1324-
[14:24..14:31):Read[T] => x$2
13251320
[14:46..14:61):summon[Read[T]] => *(x$2)
13261321

13271322
expect/ForComprehension.scala
@@ -1711,7 +1706,7 @@ Text => empty
17111706
Language => Scala
17121707
Symbols => 45 entries
17131708
Occurrences => 61 entries
1714-
Synthetics => 5 entries
1709+
Synthetics => 2 entries
17151710

17161711
Symbols:
17171712
givens/InventedNames$package. => final package object givens extends Object { self: givens.type => +24 decls }
@@ -1824,9 +1819,6 @@ Occurrences:
18241819
[41:18..41:24): String -> scala/Predef.String#
18251820

18261821
Synthetics:
1827-
[14:0..14:20):given String = "str" => given_String
1828-
[15:13..15:16):Int => x$1
1829-
[24:13..24:14):X => x$1
18301822
[34:8..34:20):given_Double => *(intValue)
18311823
[40:8..40:15):given_Y => *(given_X)
18321824

@@ -2972,7 +2964,7 @@ Text => empty
29722964
Language => Scala
29732965
Symbols => 52 entries
29742966
Occurrences => 133 entries
2975-
Synthetics => 24 entries
2967+
Synthetics => 21 entries
29762968

29772969
Symbols:
29782970
example/Synthetic# => class Synthetic extends Object { self: Synthetic => +23 decls }
@@ -3181,12 +3173,9 @@ Synthetics:
31813173
[32:35..32:49):Array.empty[T] => *(evidence$1)
31823174
[36:22..36:27):new F => orderingToOrdered[F](*)
31833175
[36:22..36:27):new F => *(ordering)
3184-
[50:26..50:29):Int => x$2
3185-
[51:17..51:20):Int => x$1
31863176
[51:24..51:30):foo(0) => *(x$1)
31873177
[52:27..52:33):foo(0) => *(x)
31883178
[55:6..55:12):foo(x) => *(x)
3189-
[57:6..57:19):given Int = 1 => given_Int
31903179
[58:6..58:12):foo(0) => *(given_Int)
31913180

31923181
expect/Traits.scala

0 commit comments

Comments
 (0)