@@ -21,6 +21,19 @@ class TypeOps:
21
21
private val paramRefSymtab = mutable.Map [(LambdaType , Name ), Symbol ]()
22
22
private val refinementSymtab = mutable.Map [(RefinedType , Name ), Symbol ]()
23
23
given typeOps : TypeOps = this
24
+
25
+ extension [T <: Type ](symtab : mutable.Map [(T , Name ), Symbol ])
26
+ private def getOrErr (key : (T , Name ))(using Context ): Option [Symbol ] =
27
+ val sym = symtab.get(key)
28
+ if sym.isEmpty then
29
+ symbolNotFound(key._1, key._2)
30
+ sym
31
+
32
+ private def symbolNotFound (binder : Type , name : Name )(using ctx : Context ): Unit =
33
+ report.warning(
34
+ s """ Internal error in extracting SemanticDB while compiling ${ctx.compilationUnit.source}: Ignoring ${name} of type ${binder}"""
35
+ )
36
+
24
37
extension (tpe : Type )
25
38
def toSemanticSig (using LinkMode , Context , SemanticSymbolBuilder )(sym : Symbol ): s.Signature =
26
39
def enterParamRef (tpe : Type ): Unit =
@@ -110,14 +123,12 @@ class TypeOps:
110
123
): (Type , List [List [Symbol ]], List [Symbol ]) = t match {
111
124
case mt : MethodType =>
112
125
val syms = mt.paramNames.flatMap { paramName =>
113
- val key = (mt, paramName)
114
- paramRefSymtab.get(key)
126
+ paramRefSymtab.getOrErr((mt, paramName))
115
127
}
116
128
flatten(mt.resType, paramss :+ syms, tparams)
117
129
case pt : PolyType =>
118
130
val syms = pt.paramNames.flatMap { paramName =>
119
- val key = (pt, paramName)
120
- paramRefSymtab.get(key)
131
+ paramRefSymtab.getOrErr((pt, paramName))
121
132
}
122
133
// there shouldn't multiple type params
123
134
flatten(pt.resType, paramss, syms)
@@ -185,7 +196,7 @@ class TypeOps:
185
196
186
197
case tref : ParamRef =>
187
198
val key = (tref.binder, tref.paramName)
188
- paramRefSymtab.get (key) match {
199
+ paramRefSymtab.getOrErr (key) match {
189
200
case Some (ref) =>
190
201
val ssym = ref.symbolName
191
202
tref match {
@@ -243,7 +254,7 @@ class TypeOps:
243
254
val stpe = s.IntersectionType (flattenParent(parent))
244
255
245
256
val decls = refinedInfos.flatMap { (name, _) =>
246
- refinementSymtab.get ((rt, name))
257
+ refinementSymtab.getOrErr ((rt, name))
247
258
}
248
259
val sdecls = decls.sscopeOpt(using LinkMode .HardlinkChildren )
249
260
s.StructuralType (stpe, sdecls)
@@ -337,6 +348,7 @@ class TypeOps:
337
348
case _ => false
338
349
}
339
350
351
+
340
352
object SymbolScopeOps :
341
353
import Scala3 .given
342
354
extension (syms : List [Symbol ])
0 commit comments