@@ -177,13 +177,15 @@ object Denotations {
177
177
}
178
178
179
179
/** Return symbol in this denotation that satisfies the given predicate.
180
- * Return a stubsymbol if denotation is a missing ref.
180
+ * if generateStubs is specified, return a stubsymbol if denotation is a missing ref.
181
181
* Throw a `TypeError` if predicate fails to disambiguate symbol or no alternative matches.
182
182
*/
183
- def requiredSymbol (p : Symbol => Boolean , source : AbstractFile = null )(implicit ctx : Context ): Symbol =
183
+ def requiredSymbol (p : Symbol => Boolean , source : AbstractFile = null , generateStubs : Boolean = true )(implicit ctx : Context ): Symbol =
184
184
disambiguate(p) match {
185
185
case MissingRef (ownerd, name) =>
186
- ctx.newStubSymbol(ownerd.symbol, name, source)
186
+ if (generateStubs)
187
+ ctx.newStubSymbol(ownerd.symbol, name, source)
188
+ else NoSymbol
187
189
case NoDenotation | _ : NoQualifyingRef =>
188
190
throw new TypeError (s " None of the alternatives of $this satisfies required predicate " )
189
191
case denot =>
@@ -874,8 +876,9 @@ object Denotations {
874
876
875
877
/** The current denotation of the static reference given by path,
876
878
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
879
+ * if generateStubs is set, generates stubs for missing top-level symbols
877
880
*/
878
- def staticRef (path : Name )(implicit ctx : Context ): Denotation = {
881
+ def staticRef (path : Name , generateStubs : Boolean = true )(implicit ctx : Context ): Denotation = {
879
882
def recur (path : Name , len : Int ): Denotation = {
880
883
val point = path.lastIndexOf('.' , len - 1 )
881
884
val owner =
@@ -887,7 +890,9 @@ object Denotations {
887
890
val result = owner.info.member(name)
888
891
if (result ne NoDenotation ) result
889
892
else {
890
- val alt = missingHook(owner.symbol.moduleClass, name)
893
+ val alt =
894
+ if (generateStubs) missingHook(owner.symbol.moduleClass, name)
895
+ else NoSymbol
891
896
if (alt.exists) alt.denot
892
897
else MissingRef (owner, name)
893
898
}
0 commit comments