Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ object Scala3:
case NameKinds.AnyNumberedName(nme.EMPTY, _) => true
case _ => false
}

def isDynamic(using Context): Boolean =
name == nme.applyDynamic ||
name == nme.selectDynamic ||
name == nme.updateDynamic ||
name == nme.applyDynamicNamed
end NameOps

given SymbolOps: AnyRef with
Expand Down
18 changes: 16 additions & 2 deletions compiler/src/dotty/tools/dotc/semanticdb/SyntheticsExtractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dotty.tools.dotc.ast.tpd._
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.StdNames.nme
import dotty.tools.dotc.core.NameKinds
import dotty.tools.dotc.{semanticdb => s}


Expand All @@ -26,8 +27,21 @@ class SyntheticsExtractor:
tree match
case tree: TypeApply
if tree.span.isSynthetic &&
tree.args.forall(arg => !arg.symbol.is(Scala2x)) &&
!tree.span.isZeroExtent =>
tree.args.forall(arg => !arg.symbol.isDefinedInSource) &&
!tree.span.isZeroExtent &&
(tree.fun match {
// for `Bar[Int]` of `class Foo extends Bar[Int]`
// we'll have `TypeTree(Select(New(AppliedTypeTree(...))), List(Int))`
// in this case, don't register `*[Int]` to synthetics as we already have `[Int]` in source.
case Select(New(AppliedTypeTree(_, _)), _) => false

// for `new SomeJavaClass[Int]()`
// there will be a synthesized default getter
// in addition to the source derived one.
case Select(_, name) if name.is(NameKinds.DefaultGetterName) => false
case Select(fun, _) if fun.symbol.name.isDynamic => false
case _ => true
}) =>
visited.add(tree)
val fnTree = tree.fun match
// Something like `List.apply[Int](1,2,3)`
Expand Down
Loading