Skip to content

Commit 2ca6fb2

Browse files
committed
Remove case property from the symbol of type variable
`t` of `case List[t] =>` has `CaseClass` flag. Maybe we should remove `CaseClass` flag from `t`, but as a workaround remove `Case` property from semanticdb from type variables.
1 parent 28d59a0 commit 2ca6fb2

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ class ExtractSemanticDB extends Phase:
433433
// if symbol isType, it's type variable
434434
case tree: Bind if (!tree.symbol.isType) =>
435435
symkinds += SymbolKind.Val
436+
case tree: Bind if (tree.symbol.isType) =>
437+
symkinds += SymbolKind.TypeVal
436438
case _ =>
437439
symkinds.toSet
438440

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ object Scala3:
153153
enum SymbolKind derives CanEqual:
154154
kind =>
155155

156-
case Val, Var, Setter, Abstract
156+
case Val, Var, Setter, Abstract, TypeVal
157157

158158
def isVar: Boolean = kind match
159159
case Var | Setter => true
160160
case _ => false
161161
def isVal: Boolean = kind == Val
162+
def isTypeVal: Boolean = kind == TypeVal
162163
def isVarOrVal: Boolean = kind.isVar || kind.isVal
163164

164165
end SymbolKind
@@ -309,7 +310,9 @@ object Scala3:
309310
props |= SymbolInformation.Property.IMPLICIT.value
310311
if sym.is(Lazy, butNot=Module) then
311312
props |= SymbolInformation.Property.LAZY.value
312-
if sym.isAllOf(Case | Module) || sym.is(CaseClass) || sym.isAllOf(EnumCase) then
313+
if sym.isAllOf(Case | Module) ||
314+
(sym.is(CaseClass) && !symkinds.exists(_.isTypeVal)) || // `t` of `case List[t] =>` (which has `CaseClass` flag) shouldn't be `CASE`
315+
sym.isAllOf(EnumCase) then
313316
props |= SymbolInformation.Property.CASE.value
314317
if sym.is(Covariant) then
315318
props |= SymbolInformation.Property.COVARIANT.value

tests/semanticdb/metac.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,10 +2034,10 @@ example/MatchType$package.Concat#[Xs] => typeparam Xs <: Tuple
20342034
example/MatchType$package.Concat#[Ys] => covariant typeparam Ys <: Tuple
20352035
example/MatchType$package.Elem# => type Elem [typeparam X ] = X match { String => Char, Array[t] => t, Iterable[t] => t }
20362036
example/MatchType$package.Elem#[X] => typeparam X
2037-
local0 => case type t
2038-
local1 => case type t
2039-
local2 => case type x
2040-
local3 => case type xs <: Tuple
2037+
local0 => type t
2038+
local1 => type t
2039+
local2 => type x
2040+
local3 => type xs <: Tuple
20412041

20422042
Occurrences:
20432043
[0:8..0:15): example <- example/
@@ -4087,9 +4087,9 @@ Occurrences => 46 entries
40874087
Synthetics => 3 entries
40884088

40894089
Symbols:
4090-
local0 => case type N$1 <: Nat
4090+
local0 => type N$1 <: Nat
40914091
local1 => val local p: N$1
4092-
local2 => case type N$2 <: Nat
4092+
local2 => type N$2 <: Nat
40934093
local3 => val local p: N$2
40944094
local4 => val local Nat_this: Zero.type
40954095
local5 => val local Nat_this: Succ[Zero.type]
@@ -4271,7 +4271,7 @@ flags/p/package.y(). => protected implicit var method y Int
42714271
flags/p/package.z(). => method z (param pp: Int): Int
42724272
flags/p/package.z().(pp) => param pp: Int
42734273
local0 => val local xs2: Nothing
4274-
local1 => case type t
4274+
local1 => type t
42754275

42764276
Occurrences:
42774277
[0:8..0:13): flags <- flags/

0 commit comments

Comments
 (0)