aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Denotations.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-20 14:04:02 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-20 14:06:43 +0200
commit815516b239f6ec6d649e71c355b803a5620abe97 (patch)
treeb4073ca60831200162afa3b43b5a9f073f566cc5 /src/dotty/tools/dotc/core/Denotations.scala
parent5f31ce4633b76b610a397d587303dba1ce5a9b02 (diff)
downloaddotty-815516b239f6ec6d649e71c355b803a5620abe97.tar.gz
dotty-815516b239f6ec6d649e71c355b803a5620abe97.tar.bz2
dotty-815516b239f6ec6d649e71c355b803a5620abe97.zip
Implement getClassIfDefined.
Diffstat (limited to 'src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index f038e8f2f..a30cff714 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -177,13 +177,15 @@ object Denotations {
}
/** Return symbol in this denotation that satisfies the given predicate.
- * Return a stubsymbol if denotation is a missing ref.
+ * if generateStubs is specified, return a stubsymbol if denotation is a missing ref.
* Throw a `TypeError` if predicate fails to disambiguate symbol or no alternative matches.
*/
- def requiredSymbol(p: Symbol => Boolean, source: AbstractFile = null)(implicit ctx: Context): Symbol =
+ def requiredSymbol(p: Symbol => Boolean, source: AbstractFile = null, generateStubs: Boolean = true)(implicit ctx: Context): Symbol =
disambiguate(p) match {
case MissingRef(ownerd, name) =>
- ctx.newStubSymbol(ownerd.symbol, name, source)
+ if (generateStubs)
+ ctx.newStubSymbol(ownerd.symbol, name, source)
+ else NoSymbol
case NoDenotation | _: NoQualifyingRef =>
throw new TypeError(s"None of the alternatives of $this satisfies required predicate")
case denot =>
@@ -874,8 +876,9 @@ object Denotations {
/** The current denotation of the static reference given by path,
* or a MissingRef or NoQualifyingRef instance, if it does not exist.
+ * if generateStubs is set, generates stubs for missing top-level symbols
*/
- def staticRef(path: Name)(implicit ctx: Context): Denotation = {
+ def staticRef(path: Name, generateStubs: Boolean = true)(implicit ctx: Context): Denotation = {
def recur(path: Name, len: Int): Denotation = {
val point = path.lastIndexOf('.', len - 1)
val owner =
@@ -887,7 +890,9 @@ object Denotations {
val result = owner.info.member(name)
if (result ne NoDenotation) result
else {
- val alt = missingHook(owner.symbol.moduleClass, name)
+ val alt =
+ if (generateStubs) missingHook(owner.symbol.moduleClass, name)
+ else NoSymbol
if (alt.exists) alt.denot
else MissingRef(owner, name)
}