Skip to content

Commit 20cc92e

Browse files
committed
Don't require loadable when trying extension methods
1 parent 19ea673 commit 20cc92e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
413413
Ident(tp)
414414
else
415415
val pre = tp.prefix
416-
if (pre.isSingleton) followOuterLinks(singleton(pre.dealias)).select(tp)
416+
if (pre.isSingleton) followOuterLinks(singleton(pre.dealias, needLoad)).select(tp)
417417
else
418418
val res = Select(TypeTree(pre), tp)
419419
if needLoad && !res.symbol.isStatic then
@@ -431,11 +431,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
431431
t
432432
}
433433

434-
def singleton(tp: Type)(using Context): Tree = tp.dealias match {
435-
case tp: TermRef => ref(tp)
434+
def singleton(tp: Type, needLoad: Boolean = true)(using Context): Tree = tp.dealias match {
435+
case tp: TermRef => ref(tp, needLoad)
436436
case tp: ThisType => This(tp.cls)
437-
case tp: SkolemType => singleton(tp.narrow)
438-
case SuperType(qual, _) => singleton(qual)
437+
case tp: SkolemType => singleton(tp.narrow, needLoad)
438+
case SuperType(qual, _) => singleton(qual, needLoad)
439439
case ConstantType(value) => Literal(value)
440440
}
441441

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ object Completion {
8585
* @param content The source content that we'll check the positions for the prefix
8686
* @param start The start position we'll start to look for the prefix at
8787
* @param end The end position we'll look for the prefix at
88-
* @return Either the full prefix including the ` or an empty string
88+
* @return Either the full prefix including the ` or an empty string
8989
*/
90-
private def checkBacktickPrefix(content: Array[Char], start: Int, end: Int): String =
90+
private def checkBacktickPrefix(content: Array[Char], start: Int, end: Int): String =
9191
content.lift(start) match
9292
case Some(char) if char == '`' =>
9393
content.slice(start, end).mkString
@@ -111,7 +111,7 @@ object Completion {
111111
// Foo.`se<TAB> will result in Select(Ident(Foo), <error>)
112112
case (select: untpd.Select) :: _ if select.name == nme.ERROR =>
113113
checkBacktickPrefix(select.source.content(), select.nameSpan.start, select.span.end)
114-
114+
115115
// import scala.util.chaining.`s<TAB> will result in a Ident(<error>)
116116
case (ident: untpd.Ident) :: _ if ident.name == nme.ERROR =>
117117
checkBacktickPrefix(ident.source.content(), ident.span.start, ident.span.end)
@@ -177,14 +177,14 @@ object Completion {
177177
// https://github.com/com-lihaoyi/Ammonite/blob/73a874173cd337f953a3edc9fb8cb96556638fdd/amm/util/src/main/scala/ammonite/util/Model.scala
178178
private def needsBacktick(s: String) =
179179
val chunks = s.split("_", -1)
180-
180+
181181
val validChunks = chunks.zipWithIndex.forall { case (chunk, index) =>
182182
chunk.forall(Chars.isIdentifierPart) ||
183183
(chunk.forall(Chars.isOperatorPart) &&
184184
index == chunks.length - 1 &&
185185
!(chunks.lift(index - 1).contains("") && index - 1 == 0))
186186
}
187-
187+
188188
val validStart =
189189
Chars.isIdentifierStart(s(0)) || chunks(0).forall(Chars.isOperatorPart)
190190

@@ -312,7 +312,7 @@ object Completion {
312312

313313
/** Replaces underlying type with reduced one, when it's MatchType */
314314
def reduceUnderlyingMatchType(qual: Tree)(using Context): Tree=
315-
qual.tpe.widen match
315+
qual.tpe.widen match
316316
case ctx.typer.MatchTypeInDisguise(mt) => qual.withType(mt)
317317
case _ => qual
318318

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ trait Applications extends Compatibility {
22682268
case TypeApply(fun, args) => TypeApply(replaceCallee(fun, replacement), args)
22692269
case _ => replacement
22702270

2271-
val methodRefTree = ref(methodRef)
2271+
val methodRefTree = ref(methodRef, needLoad = false)
22722272
val truncatedSym = methodRef.symbol.asTerm.copy(info = truncateExtension(methodRef.info))
22732273
val truncatedRefTree = untpd.TypedSplice(ref(truncatedSym)).withSpan(receiver.span)
22742274
val newCtx = ctx.fresh.setNewScope.setReporter(new reporting.ThrowingReporter(ctx.reporter))

0 commit comments

Comments
 (0)