Skip to content

chore: LTS backports #20855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
72a5416
chore: Backport changes from Metals
tgodzik Jan 10, 2024
d673901
Better error diagnostics for cyclic references
odersky Jan 10, 2024
55fa46d
Update compiler/src/dotty/tools/dotc/core/SymDenotations.scala
odersky Jan 11, 2024
770481e
Update check files to new error message wording
odersky Jan 11, 2024
a32e14a
Fix a completion test failing on java 8
jchyb Jan 12, 2024
6c84356
Consider static and non-static methods as non-double def
dwijnand Jan 8, 2024
d54ba6d
Fix static method js backend
dwijnand Jan 9, 2024
398ffc5
Add other cases fixed by js backend fix
dwijnand Jan 12, 2024
bcb72d3
Add regression test for #18260
nicolasstucki Dec 4, 2023
186fb72
Make SBT `clean` clean `scala2-library-bootstrapped` and `scala2-libr…
nicolasstucki Jan 15, 2024
81e02c6
Add a test case, proving i15661 is fixed
dwijnand Jan 12, 2024
a9962c1
Scaladoc - add option for dynamic side menu
WojciechMazur Jun 27, 2024
3bc09f3
Don't leave underspecified SAM types in the code
odersky Jan 16, 2024
f7d07f5
Reject wildcard types in using clauses
odersky Jan 16, 2024
d74f680
Fix problems with cycle checks
odersky Jan 15, 2024
679fd17
Cheaper test for isInteresting in cycle checking
odersky Jan 16, 2024
577b6f7
chore: backport changes from metals
jkciesluk Jan 16, 2024
8ed96aa
Clean `scala2-library` on `scala3-bootstrapped/clean`
nicolasstucki Jan 15, 2024
97735ed
Also compute base classes of wildcardTypes
odersky Jan 17, 2024
f146635
Workaround #19542
WojciechMazur Jun 27, 2024
3005598
Update `staging.Compiler.make` documentation
nicolasstucki Jan 12, 2024
e9f2ab0
Add extra info in unqualified `getClass` warning
nicolasstucki Jan 12, 2024
fb8f8df
Give better feedback for classloader failure in staging
nicolasstucki Jan 12, 2024
6714d39
Disable i19170b on Windows
nicolasstucki Jan 18, 2024
29a9b9f
Passing NotNullInfos to a mutable field of a Completer
noti0na1 Jan 16, 2024
a1ff530
Make myNotNullInfos field private
noti0na1 Jan 18, 2024
a1afca6
Change the name of dummy type parameter
noti0na1 Jan 19, 2024
da600b6
Add a comment for myNotNullInfos
noti0na1 Jan 19, 2024
b7b89a2
Make order of renames and missing imports deterministic
nicolasstucki Jan 18, 2024
a574467
Second batch of neg -> warn test changes
WojciechMazur Jun 27, 2024
2ba59e5
Review fixes
WojciechMazur Jun 27, 2024
1168afb
Improve signature help by more stable position calculation + better n…
rochala Jan 19, 2024
c4d6ab2
Make PC more resiliant to crashes
rochala Jan 19, 2024
2296b60
Disable i19170b on JDK8
nicolasstucki Jan 19, 2024
6fe1132
Backport "chore: Backport changes from Metals" to LTS (#20823)
WojciechMazur Jun 28, 2024
6d207ab
Backport "Better error diagnostics for cyclic references" to LTS (#20…
WojciechMazur Jun 28, 2024
02ebf61
Backport "Fix main: completion test failing on java 8" to LTS (#20825)
WojciechMazur Jun 28, 2024
fdb2ced
Backport "Consider static and non-static methods as non-double def" t…
WojciechMazur Jun 28, 2024
366dbf9
Backport "Add regression test for #18260" to LTS (#20827)
WojciechMazur Jun 28, 2024
372e437
Backport "Make SBT `clean` clean `scala2-library-bootstrapped` and `s…
WojciechMazur Jun 28, 2024
902e332
Backport "Add a test case, proving i15661 is fixed" to LTS (#20829)
WojciechMazur Jun 28, 2024
724fb71
Backport "Scaladoc - add option for dynamic side menu" to LTS (#20830)
WojciechMazur Jun 28, 2024
ea9a722
Backport "Don't leave underspecified SAM types in the code" to LTS (#…
WojciechMazur Jun 28, 2024
c0b8c17
Backport "Reject wildcard types in using clauses" to LTS (#20832)
WojciechMazur Jun 28, 2024
958acc6
Backport "Fix problems with cycle checks" to LTS (#20833)
WojciechMazur Jun 28, 2024
a010f00
Backport "chore: backport changes from metals" to LTS (#20834)
WojciechMazur Jun 28, 2024
1053113
Backport "Clean `scala2-library` on `scala3-bootstrapped/clean`" to L…
WojciechMazur Jun 28, 2024
e4e2ffe
Backport "Also compute base classes of wildcardTypes" to LTS (#20836)
WojciechMazur Jun 28, 2024
5982b8a
Backport "Workaround #19542" to LTS (#20838)
WojciechMazur Jun 28, 2024
d1041f6
Backport "Update `staging.Compiler.make` documentation" to LTS (#20839)
WojciechMazur Jun 28, 2024
0fd4aae
Backport "Disable i19170b on Windows" to LTS (#20840)
WojciechMazur Jun 28, 2024
2152d15
Backport "Fix #19202: Passing NotNullInfos to a mutable field of a Co…
WojciechMazur Jun 28, 2024
9842c9e
Backport "Make order of renames and missing imports deterministic" to…
WojciechMazur Jun 28, 2024
244ecdf
Backport "Move warn tests from tests/neg to tests/warn: Batch 2" to L…
WojciechMazur Jun 28, 2024
6dcfeab
Backport "Improve signature help by more stable position calculation …
WojciechMazur Jun 28, 2024
f2418bf
Backport "Make PC more resilient to crashes" to LTS (#20846)
WojciechMazur Jun 28, 2024
f87f2cf
Backport "Disable i19170b on JDK8" to LTS (#20847)
WojciechMazur Jun 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,9 @@ class JSCodeGen()(using genCtx: Context) {
name.name
}.toSet

val staticNames = moduleClass.companionClass.info.allMembers
.collect { case d if d.name.isTermName && d.symbol.isScalaStatic => d.name }.toSet

val members = {
moduleClass.info.membersBasedOnFlags(required = Flags.Method,
excluded = Flags.ExcludedForwarder).map(_.symbol)
Expand All @@ -815,6 +818,7 @@ class JSCodeGen()(using genCtx: Context) {
|| hasAccessBoundary
|| isOfJLObject
|| m.hasAnnotation(jsdefn.JSNativeAnnot) || isDefaultParamOfJSNativeDef // #4557
|| staticNames(m.name)
}

val forwarders = for {
Expand Down Expand Up @@ -4769,7 +4773,7 @@ class JSCodeGen()(using genCtx: Context) {
}

private def isMethodStaticInIR(sym: Symbol): Boolean =
sym.is(JavaStatic)
sym.is(JavaStatic) || sym.isScalaStatic

/** Generate a Class[_] value (e.g. coming from classOf[T]) */
private def genClassConstant(tpe: Type)(implicit pos: Position): js.Tree =
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
runCtx.setProfiler(Profiler())
unfusedPhases.foreach(_.initContext(runCtx))
val fusedPhases = runCtx.base.allPhases
if ctx.settings.explainCyclic.value then
runCtx.setProperty(CyclicReference.Trace, new CyclicReference.Trace())
runCtx.withProgressCallback: cb =>
_progress = Progress(cb, this, fusedPhases.map(_.traversals).sum)
runPhases(allPhases = fusedPhases)(using runCtx)
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ trait CommonScalaSettings:
// -explain-types setting is necessary for cross compilation, since it is mentioned in sbt-tpolecat, for instance
// it is otherwise subsumed by -explain, and should be dropped as soon as we can.
val explainTypes: Setting[Boolean] = BooleanSetting("-explain-types", "Explain type errors in more detail (deprecated, use -explain instead).", aliases = List("--explain-types", "-explaintypes"))
val explainCyclic: Setting[Boolean] = BooleanSetting("-explain-cyclic", "Explain cyclic reference errors in more detail.", aliases = List("--explain-cyclic"))
val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", initialValue = true, aliases = List("--unchecked"))
val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.", aliases = List("--language"))

Expand Down Expand Up @@ -347,6 +348,7 @@ private sealed trait YSettings:
val YdebugTypeError: Setting[Boolean] = BooleanSetting("-Ydebug-type-error", "Print the stack trace when a TypeError is caught", false)
val YdebugError: Setting[Boolean] = BooleanSetting("-Ydebug-error", "Print the stack trace when any error is caught.", false)
val YdebugUnpickling: Setting[Boolean] = BooleanSetting("-Ydebug-unpickling", "Print the stack trace when an error occurs when reading Tasty.", false)
val YdebugCyclic: Setting[Boolean] = BooleanSetting("-Ydebug-cyclic", "Print the stack trace when a cyclic reference error occurs.", false)
val YtermConflict: Setting[String] = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error")
val Ylog: Setting[List[String]] = PhasesSetting("-Ylog", "Log operations during")
val YlogClasspath: Setting[Boolean] = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.")
Expand Down
24 changes: 17 additions & 7 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,17 @@ object SymDenotations {
println(i"${" " * indent}completed $name in $owner")
}
}
else {
if (myFlags.is(Touched))
throw CyclicReference(this)(using ctx.withOwner(symbol))
myFlags |= Touched
atPhase(validFor.firstPhaseId)(completer.complete(this))
}
else
val traceCycles = CyclicReference.isTraced
try
if traceCycles then
CyclicReference.pushTrace("compute the signature of ", symbol, "")
if myFlags.is(Touched) then
throw CyclicReference(this)(using ctx.withOwner(symbol))
myFlags |= Touched
atPhase(validFor.firstPhaseId)(completer.complete(this))
finally
if traceCycles then CyclicReference.popTrace()

protected[dotc] def info_=(tp: Type): Unit = {
/* // DEBUG
Expand Down Expand Up @@ -2965,7 +2970,10 @@ object SymDenotations {
def apply(clsd: ClassDenotation)(implicit onBehalf: BaseData, ctx: Context)
: (List[ClassSymbol], BaseClassSet) = {
assert(isValid)
val traceCycles = CyclicReference.isTraced
try
if traceCycles then
CyclicReference.pushTrace("compute the base classes of ", clsd.symbol, "")
if (cache != null) cache.uncheckedNN
else {
if (locked) throw CyclicReference(clsd)
Expand All @@ -2978,7 +2986,9 @@ object SymDenotations {
else onBehalf.signalProvisional()
computed
}
finally addDependent(onBehalf)
finally
if traceCycles then CyclicReference.popTrace()
addDependent(onBehalf)
}

def sameGroup(p1: Phase, p2: Phase) = p1.sameParentsStartId == p2.sameParentsStartId
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ object Symbols extends SymUtils {
final def lastKnownDenotation: SymDenotation =
lastDenot

private[core] def defRunId: RunId =
private[dotc] def defRunId: RunId =
lastDenot.validFor.runId

private inline def associatedFileMatches(inline filter: AbstractFile => Boolean)(using Context): Boolean =
Expand Down
39 changes: 30 additions & 9 deletions compiler/src/dotty/tools/dotc/core/TypeErrors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import Denotations.*
import Decorators.*
import reporting.*
import ast.untpd
import util.Property
import config.Printers.{cyclicErrors, noPrinter}
import collection.mutable

import scala.annotation.constructorOnly

Expand All @@ -27,6 +29,7 @@ abstract class TypeError(using creationContext: Context) extends Exception(""):
|| ctx.settings.YdebugTypeError.value
|| ctx.settings.YdebugError.value
|| ctx.settings.YdebugUnpickling.value
|| ctx.settings.YdebugCyclic.value

override def fillInStackTrace(): Throwable =
if computeStackTrace then super.fillInStackTrace().nn
Expand Down Expand Up @@ -72,8 +75,7 @@ extends TypeError:
def explanation: String = s"$op $details"

private def recursions: List[RecursionOverflow] = {
import scala.collection.mutable.ListBuffer
val result = ListBuffer.empty[RecursionOverflow]
val result = mutable.ListBuffer.empty[RecursionOverflow]
@annotation.tailrec def loop(throwable: Throwable): List[RecursionOverflow] = throwable match {
case ro: RecursionOverflow =>
result += ro
Expand Down Expand Up @@ -135,7 +137,10 @@ end handleRecursive
* so it requires knowing denot already.
* @param denot
*/
class CyclicReference(val denot: SymDenotation)(using Context) extends TypeError:
class CyclicReference(
val denot: SymDenotation,
val optTrace: Option[Array[CyclicReference.TraceElement]])(using Context)
extends TypeError:
var inImplicitSearch: Boolean = false

val cycleSym = denot.symbol
Expand All @@ -161,11 +166,11 @@ class CyclicReference(val denot: SymDenotation)(using Context) extends TypeError
cx.tree match {
case tree: untpd.ValOrDefDef if !tree.tpt.typeOpt.exists =>
if (inImplicitSearch)
TermMemberNeedsResultTypeForImplicitSearch(cycleSym)
TermMemberNeedsResultTypeForImplicitSearch(this)
else if (isMethod)
OverloadedOrRecursiveMethodNeedsResultType(cycleSym)
OverloadedOrRecursiveMethodNeedsResultType(this)
else if (isVal)
RecursiveValueNeedsResultType(cycleSym)
RecursiveValueNeedsResultType(this)
else
errorMsg(cx.outer)
case _ =>
Expand All @@ -174,22 +179,38 @@ class CyclicReference(val denot: SymDenotation)(using Context) extends TypeError

// Give up and give generic errors.
else if (cycleSym.isOneOf(GivenOrImplicitVal, butNot = Method) && cycleSym.owner.isTerm)
CyclicReferenceInvolvingImplicit(cycleSym)
CyclicReferenceInvolvingImplicit(this)
else
CyclicReferenceInvolving(denot)
CyclicReferenceInvolving(this)

errorMsg(ctx)
end toMessage

object CyclicReference:

def apply(denot: SymDenotation)(using Context): CyclicReference =
val ex = new CyclicReference(denot)
val ex = new CyclicReference(denot, ctx.property(Trace).map(_.toArray))
if ex.computeStackTrace then
cyclicErrors.println(s"Cyclic reference involving! $denot")
val sts = ex.getStackTrace.asInstanceOf[Array[StackTraceElement]]
for (elem <- sts take 200)
cyclicErrors.println(elem.toString)
ex

type TraceElement = (/*prefix:*/ String, Symbol, /*suffix:*/ String)
type Trace = mutable.ArrayBuffer[TraceElement]
val Trace = Property.Key[Trace]

def isTraced(using Context) =
ctx.property(CyclicReference.Trace).isDefined

def pushTrace(info: TraceElement)(using Context): Unit =
for buf <- ctx.property(CyclicReference.Trace) do
buf += info

def popTrace()(using Context): Unit =
for buf <- ctx.property(CyclicReference.Trace) do
buf.dropRightInPlace(1)
end CyclicReference

class UnpicklingError(denot: Denotation, where: String, cause: Throwable)(using Context) extends TypeError:
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ object Types extends TypeUtils {
tp.superType.baseClasses
case tp: ClassInfo =>
tp.cls.classDenot.baseClasses
case tp: WildcardType =>
tp.effectiveBounds.hi.baseClasses
case _ => Nil
catch case ex: Throwable =>
handleRecursive("base classes of", this.show, ex)
Expand Down
15 changes: 10 additions & 5 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,25 @@ class TreeUnpickler(reader: TastyReader,
val mode = ctx.mode
val source = ctx.source
def complete(denot: SymDenotation)(using Context): Unit =
def fail(ex: Throwable) =
def where =
val f = denot.symbol.associatedFile
if f == null then "" else s" in $f"
throw UnpicklingError(denot, where, ex)
def where =
val f = denot.symbol.associatedFile
if f == null then "" else s" in $f"
def fail(ex: Throwable) = throw UnpicklingError(denot, where, ex)
treeAtAddr(currentAddr) =
val traceCycles = CyclicReference.isTraced
try
if traceCycles then
CyclicReference.pushTrace("read the definition of ", denot.symbol, where)
atPhaseBeforeTransforms {
new TreeReader(reader).readIndexedDef()(
using ctx.withOwner(owner).withModeBits(mode).withSource(source))
}
catch
case ex: CyclicReference => throw ex
case ex: AssertionError => fail(ex)
case ex: Exception => fail(ex)
finally
if traceCycles then CyclicReference.popTrace()
}

class TreeReader(val reader: TastyReader) {
Expand Down
48 changes: 26 additions & 22 deletions compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ object Completion:
val completions = adjustedPath match
// Ignore synthetic select from `This` because in code it was `Ident`
// See example in dotty.tools.languageserver.CompletionTest.syntheticThis
case Select(qual @ This(_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions
case Select(qual, _) :: _ if qual.tpe.hasSimpleKind => completer.selectionCompletions(qual)
case Select(qual, _) :: _ => Map.empty
case (tree: ImportOrExport) :: _ => completer.directMemberCompletions(tree.expr)
case (_: untpd.ImportSelector) :: Import(expr, _) :: _ => completer.directMemberCompletions(expr)
case _ => completer.scopeCompletions
case Select(qual @ This(_), _) :: _ if qual.span.isSynthetic => completer.scopeCompletions
case Select(qual, _) :: _ if qual.typeOpt.hasSimpleKind => completer.selectionCompletions(qual)
case Select(qual, _) :: _ => Map.empty
case (tree: ImportOrExport) :: _ => completer.directMemberCompletions(tree.expr)
case (_: untpd.ImportSelector) :: Import(expr, _) :: _ => completer.directMemberCompletions(expr)
case _ => completer.scopeCompletions

val describedCompletions = describeCompletions(completions)
val backtickedCompletions =
Expand Down Expand Up @@ -348,7 +348,7 @@ object Completion:
/** Widen only those types which are applied or are exactly nothing
*/
def widenQualifier(qual: Tree)(using Context): Tree =
qual.tpe.widenDealias match
qual.typeOpt.widenDealias match
case widenedType if widenedType.isExactlyNothing => qual.withType(widenedType)
case appliedType: AppliedType => qual.withType(appliedType)
case _ => qual
Expand All @@ -368,10 +368,10 @@ object Completion:
* These include inherited definitions but not members added by extensions or implicit conversions
*/
def directMemberCompletions(qual: Tree)(using Context): CompletionMap =
if qual.tpe.isExactlyNothing then
if qual.typeOpt.isExactlyNothing then
Map.empty
else
accessibleMembers(qual.tpe).groupByName
accessibleMembers(qual.typeOpt).groupByName

/** Completions introduced by imports directly in this context.
* Completions from outer contexts are not included.
Expand Down Expand Up @@ -415,7 +415,7 @@ object Completion:

/** Completions from implicit conversions including old style extensions using implicit classes */
private def implicitConversionMemberCompletions(qual: Tree)(using Context): CompletionMap =
if qual.tpe.isExactlyNothing || qual.tpe.isNullType then
if qual.typeOpt.isExactlyNothing || qual.typeOpt.isNullType then
Map.empty
else
implicitConversionTargets(qual)(using ctx.fresh.setExploreTyperState())
Expand All @@ -432,7 +432,7 @@ object Completion:
def tryApplyingReceiverToExtension(termRef: TermRef): Option[SingleDenotation] =
ctx.typer.tryApplyingExtensionMethod(termRef, qual)
.map { tree =>
val tpe = asDefLikeType(tree.tpe.dealias)
val tpe = asDefLikeType(tree.typeOpt.dealias)
termRef.denot.asSingleDenotation.mapInfo(_ => tpe)
}

Expand All @@ -453,16 +453,16 @@ object Completion:

// 1. The extension method is visible under a simple name, by being defined or inherited or imported in a scope enclosing the reference.
val termCompleter = new Completer(Mode.Term, prefix, pos)
val extMethodsInScope = termCompleter.scopeCompletions.toList.flatMap {
case (name, denots) => denots.collect { case d: SymDenotation if d.isTerm => (d.termRef, name.asTermName) }
}
val extMethodsInScope = termCompleter.scopeCompletions.toList.flatMap:
case (name, denots) => denots.collect:
case d: SymDenotation if d.isTerm && d.termRef.symbol.is(Extension) => (d.termRef, name.asTermName)

// 2. The extension method is a member of some given instance that is visible at the point of the reference.
val givensInScope = ctx.implicits.eligible(defn.AnyType).map(_.implicitRef.underlyingRef)
val extMethodsFromGivensInScope = extractMemberExtensionMethods(givensInScope)

// 3. The reference is of the form r.m and the extension method is defined in the implicit scope of the type of r.
val implicitScopeCompanions = ctx.run.nn.implicitScope(qual.tpe).companionRefs.showAsList
val implicitScopeCompanions = ctx.run.nn.implicitScope(qual.typeOpt).companionRefs.showAsList
val extMethodsFromImplicitScope = extractMemberExtensionMethods(implicitScopeCompanions)

// 4. The reference is of the form r.m and the extension method is defined in some given instance in the implicit scope of the type of r.
Expand All @@ -472,7 +472,7 @@ object Completion:
val availableExtMethods = extMethodsFromGivensInImplicitScope ++ extMethodsFromImplicitScope ++ extMethodsFromGivensInScope ++ extMethodsInScope
val extMethodsWithAppliedReceiver = availableExtMethods.flatMap {
case (termRef, termName) =>
if termRef.symbol.is(ExtensionMethod) && !qual.tpe.isBottomType then
if termRef.symbol.is(ExtensionMethod) && !qual.typeOpt.isBottomType then
tryApplyingReceiverToExtension(termRef)
.map(denot => termName -> denot)
else None
Expand Down Expand Up @@ -551,21 +551,25 @@ object Completion:
* @param qual The argument to which the implicit conversion should be applied.
* @return The set of types after `qual` implicit conversion.
*/
private def implicitConversionTargets(qual: Tree)(using Context): Set[Type] = {
private def implicitConversionTargets(qual: Tree)(using Context): Set[Type] =
val typer = ctx.typer
val conversions = new typer.ImplicitSearch(defn.AnyType, qual, pos.span).allImplicits
val targets = conversions.map(_.tree.tpe)
val targets = try {
val conversions = new typer.ImplicitSearch(defn.AnyType, qual, pos.span).allImplicits
conversions.map(_.tree.typeOpt)
} catch {
case _ =>
interactiv.println(i"implicit conversion targets failed: ${qual.show}")
Set.empty
}

interactiv.println(i"implicit conversion targets considered: ${targets.toList}%, %")
targets
}

/** Filter for names that should appear when looking for completions. */
private object completionsFilter extends NameFilter {
private object completionsFilter extends NameFilter:
def apply(pre: Type, name: Name)(using Context): Boolean =
!name.isConstructorName && name.toTermName.info.kind == SimpleNameKind
def isStable = true
}

extension (denotations: Seq[SingleDenotation])
def groupByName(using Context): CompletionMap = denotations.groupBy(_.name)
Expand Down
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/interactive/Interactive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,10 @@ object Interactive {
case nested :: encl :: rest =>
val outer = contextOfPath(encl :: rest)
try encl match {
case tree @ PackageDef(pkg, stats) =>
assert(tree.symbol.exists)
case tree @ PackageDef(pkg, stats) if tree.symbol.exists =>
if (nested `eq` pkg) outer
else contextOfStat(stats, nested, pkg.symbol.moduleClass, outer.packageContext(tree, tree.symbol))
case tree: DefDef =>
assert(tree.symbol.exists)
case tree: DefDef if tree.symbol.exists =>
val localCtx = outer.localContext(tree, tree.symbol).setNewScope
for params <- tree.paramss; param <- params do localCtx.enter(param.symbol)
// Note: this overapproximates visibility a bit, since value parameters are only visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
if (t.symbol.exists && t.hasType) {
if (!t.symbol.isCompleted) t.symbol.info = UnspecifiedErrorType
t.symbol.annotations.foreach { annot =>
/* In some cases annotations are are used on themself (possibly larger cycles).
/* In some cases annotations are used on themself (possibly larger cycles).
* This is the case with the java.lang.annotation.Target annotation, would end
* in an infinite loop while cleaning. The `seen` is added to ensure that those
* trees are not cleand twice.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,7 @@ object Parsers {
/** ContextTypes ::= FunArgType {‘,’ FunArgType}
*/
def contextTypes(paramOwner: ParamOwner, numLeadParams: Int, impliedMods: Modifiers): List[ValDef] =
val tps = commaSeparated(funArgType)
val tps = commaSeparated(() => paramTypeOf(toplevelTyp))
var counter = numLeadParams
def nextIdx = { counter += 1; counter }
val paramFlags = if paramOwner.isClass then LocalParamAccessor else Param
Expand Down
Loading