Skip to content

Commit 2f13751

Browse files
committed
None for empty decls
1 parent 3b144a7 commit 2f13751

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,19 @@ class TypeOps:
127127
val (resType, paramss, tparams) = flatten(mp, Nil, Nil)
128128

129129
val sparamss = paramss.map(_.sscope)
130-
val stparams = Some(tparams.sscope)
130+
val stparams = tparams.sscopeOpt
131131
s.MethodSignature(
132132
stparams,
133133
sparamss,
134134
resType.toSemanticType
135135
)
136136

137137
case cls: ClassInfo =>
138-
val stparams =
139-
if (cls.cls.typeParams.nonEmpty)
140-
Some(cls.cls.typeParams.sscope)
141-
else None
138+
val stparams = cls.cls.typeParams.sscopeOpt
142139
val sparents = cls.parents.map(_.toSemanticType)
143140
val sself = cls.selfType.toSemanticType
144-
val decls = cls.decls.toList.sscope
145-
s.ClassSignature(stparams, sparents, sself, Some(decls))
141+
val decls = cls.decls.toList.sscopeOpt
142+
s.ClassSignature(stparams, sparents, sself, decls)
146143

147144
case TypeBounds(lo, hi) =>
148145
// for `type X[T] = T` is equivalent to `[T] =>> T`
@@ -159,8 +156,8 @@ class TypeOps:
159156
val params = (loParams ++ hiParams).distinctBy(_.name)
160157
val slo = loRes.toSemanticType
161158
val shi = hiRes.toSemanticType
162-
val stparams = params.sscope
163-
s.TypeSignature(Some(stparams), slo, shi)
159+
val stparams = params.sscopeOpt
160+
s.TypeSignature(stparams, slo, shi)
164161

165162
case other =>
166163
s.ValueSignature(
@@ -248,8 +245,8 @@ class TypeOps:
248245
val decls = refinedInfos.flatMap { (name, _) =>
249246
refinementSymtab.get((rt, name))
250247
}
251-
val sdecls = decls.sscope(using LinkMode.HardlinkChildren)
252-
s.StructuralType(stpe, Some(sdecls))
248+
val sdecls = decls.sscopeOpt(using LinkMode.HardlinkChildren)
249+
s.StructuralType(stpe, sdecls)
253250

254251
case rec: RecType =>
255252
loop(rec.parent) // should be handled as RefinedType
@@ -304,7 +301,7 @@ class TypeOps:
304301
if (wildcardSyms.isEmpty) applied
305302
else s.ExistentialType(
306303
applied,
307-
Some(wildcardSyms.sscope(using LinkMode.HardlinkChildren))
304+
wildcardSyms.sscopeOpt(using LinkMode.HardlinkChildren)
308305
)
309306

310307
case and: AndType =>
@@ -350,3 +347,6 @@ object SymbolScopeOps:
350347
case LinkMode.HardlinkChildren =>
351348
s.Scope(hardlinks = syms.map(_.symbolInfo(Set.empty)))
352349
}
350+
351+
def sscopeOpt(using linkMode: LinkMode)(using SemanticSymbolBuilder, TypeOps, Context): Option[s.Scope] =
352+
if syms.nonEmpty then Some(syms.sscope) else None

0 commit comments

Comments
 (0)