diff --git a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala index 9ac860a33112..aa1d7b102fb5 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala @@ -80,6 +80,7 @@ class ExtractSemanticDB extends Phase: || sym.is(Synthetic) || sym.isSetter || sym.isOldStyleImplicitConversion(forImplicitClassOnly = true) + || sym.owner.isGivenInstanceSummoner || excludeDefOrUse(sym) private def excludeDefOrUse(sym: Symbol)(using Context): Boolean = diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index 7991cd752acf..30906e9b1356 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -100,6 +100,17 @@ object SymUtils: case _ => false + def isGivenInstanceSummoner(using Context): Boolean = + def isCodefined(info: Type): Boolean = info.stripPoly match + case mt: MethodType => + // given summoner can only have contextual params + mt.isImplicitMethod && isCodefined(mt.resultType) + case mt: ExprType => + isCodefined(mt.resultType) + case res => + self.isCoDefinedGiven(res.typeSymbol) + self.isAllOf(Given | Method) && isCodefined(self.info) + def useCompanionAsMirror(using Context): Boolean = self.linkedClass.exists && !self.is(Scala2x) /** Is this a sealed class or trait for which a sum mirror is generated? diff --git a/tests/semanticdb/expect/InventedNames.expect.scala b/tests/semanticdb/expect/InventedNames.expect.scala index 6f0ae238ce7b..7c5b008209c2 100644 --- a/tests/semanticdb/expect/InventedNames.expect.scala +++ b/tests/semanticdb/expect/InventedNames.expect.scala @@ -25,7 +25,7 @@ given X/*->givens::X#*/ with given (using X/*->givens::X#*/): Y/*->givens::Y#*/ with def doY/*<-givens::InventedNames$package.given_Y#doY().*/ = "7" -given [T/*<-givens::InventedNames$package.given_Z_T#[T]*//*<-givens::InventedNames$package.given_Z_T().[T]*/]: Z/*->givens::Z#*/[T/*->givens::InventedNames$package.given_Z_T#[T]*/] with +given [T/*<-givens::InventedNames$package.given_Z_T#[T]*/]: Z/*->givens::Z#*/[T/*->givens::InventedNames$package.given_Z_T#[T]*/] with def doZ/*<-givens::InventedNames$package.given_Z_T#doZ().*/: List/*->scala::package.List#*/[T/*->givens::InventedNames$package.given_Z_T#[T]*/] = Nil/*->scala::package.Nil.*/ @@ -39,4 +39,4 @@ val f/*<-givens::InventedNames$package.f.*/ = given_Float/*->givens::InventedNam val g/*<-givens::InventedNames$package.g.*/ = `* *`/*->givens::InventedNames$package.`* *`.*/ val x/*<-givens::InventedNames$package.x.*/ = given_X/*->givens::InventedNames$package.given_X.*/ val y/*<-givens::InventedNames$package.y.*/ = given_Y/*->givens::InventedNames$package.given_Y().*/ -val z/*<-givens::InventedNames$package.z.*/ = given_Z_T/*->givens::InventedNames$package.given_Z_T().*/[String/*->scala::Predef.String#*/] \ No newline at end of file +val z/*<-givens::InventedNames$package.z.*/ = given_Z_T/*->givens::InventedNames$package.given_Z_T().*/[String/*->scala::Predef.String#*/] diff --git a/tests/semanticdb/expect/InventedNames.scala b/tests/semanticdb/expect/InventedNames.scala index 3858f22c8331..42c14c90e370 100644 --- a/tests/semanticdb/expect/InventedNames.scala +++ b/tests/semanticdb/expect/InventedNames.scala @@ -39,4 +39,4 @@ val f = given_Float val g = `* *` val x = given_X val y = given_Y -val z = given_Z_T[String] \ No newline at end of file +val z = given_Z_T[String] diff --git a/tests/semanticdb/metac.expect b/tests/semanticdb/metac.expect index 61109db50024..d66bf1dc17dd 100644 --- a/tests/semanticdb/metac.expect +++ b/tests/semanticdb/metac.expect @@ -1684,7 +1684,7 @@ Uri => InventedNames.scala Text => empty Language => Scala Symbols => 45 entries -Occurrences => 62 entries +Occurrences => 61 entries Symbols: givens/InventedNames$package. => final package object givens extends Object { self: givens.type => +24 decls } @@ -1767,7 +1767,6 @@ Occurrences: [24:17..24:18): Y -> givens/Y# [25:6..25:9): doY <- givens/InventedNames$package.given_Y#doY(). [27:7..27:8): T <- givens/InventedNames$package.given_Z_T#[T] -[27:7..27:8): T <- givens/InventedNames$package.given_Z_T().[T] [27:11..27:12): Z -> givens/Z# [27:13..27:14): T -> givens/InventedNames$package.given_Z_T#[T] [28:6..28:9): doZ <- givens/InventedNames$package.given_Z_T#doZ().