File tree Expand file tree Collapse file tree 5 files changed +20
-13
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 5 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ class ExtractSemanticDB extends Phase:
79
79
|| sym.isLocalDummy
80
80
|| sym.is(Synthetic )
81
81
|| sym.isSetter
82
+ || sym.isOldStyleImplicitConversion(forImplicitClassOnly = true )
82
83
|| excludeDefOrUse(sym)
83
84
84
85
private def excludeDefOrUse (sym : Symbol )(using Context ): Boolean =
@@ -102,6 +103,7 @@ class ExtractSemanticDB extends Phase:
102
103
private def excludeChildren (sym : Symbol )(using Context ): Boolean =
103
104
! sym.exists
104
105
|| sym.is(Param ) && sym.info.bounds.hi.isInstanceOf [Types .HKTypeLambda ]
106
+ || sym.isOldStyleImplicitConversion(forImplicitClassOnly = true )
105
107
106
108
/** Uses of this symbol where the reference has given span should be excluded from semanticdb */
107
109
private def excludeUse (qualifier : Option [Symbol ], sym : Symbol )(using Context ): Boolean =
Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ object SymUtils:
87
87
88
88
def isGenericProduct (using Context ): Boolean = whyNotGenericProduct.isEmpty
89
89
90
+ /** Is this the an old style implicit conversion?
91
+ * @param directOnly only consider explicitly written methods
92
+ * @param forImplicitClassOnly only consider methods generated from implicit classes
93
+ */
94
+ def isOldStyleImplicitConversion (directOnly : Boolean = false , forImplicitClassOnly : Boolean = false )(using Context ): Boolean =
95
+ self.is(Implicit ) && self.info.stripPoly.match
96
+ case mt @ MethodType (_ :: Nil ) if ! mt.isImplicitMethod =>
97
+ if self.isCoDefinedGiven(mt.finalResultType.typeSymbol)
98
+ then ! directOnly
99
+ else ! forImplicitClassOnly
100
+ case _ =>
101
+ false
102
+
90
103
def useCompanionAsMirror (using Context ): Boolean = self.linkedClass.exists && ! self.is(Scala2x )
91
104
92
105
/** Is this a sealed class or trait for which a sum mirror is generated?
Original file line number Diff line number Diff line change @@ -861,23 +861,14 @@ trait Checking {
861
861
/** If `sym` is an old-style implicit conversion, check that implicit conversions are enabled.
862
862
* @pre sym.is(GivenOrImplicit)
863
863
*/
864
- def checkImplicitConversionDefOK (sym : Symbol )(using Context ): Unit = {
865
- def check () : Unit =
864
+ def checkImplicitConversionDefOK (sym : Symbol )(using Context ): Unit =
865
+ if sym.isOldStyleImplicitConversion(directOnly = true ) then
866
866
checkFeature(
867
867
nme.implicitConversions,
868
868
i " Definition of implicit conversion $sym" ,
869
869
ctx.owner.topLevelClass,
870
870
sym.srcPos)
871
871
872
- sym.info.stripPoly match {
873
- case mt @ MethodType (_ :: Nil )
874
- if ! mt.isImplicitMethod && ! sym.isCoDefinedGiven(mt.finalResultType.typeSymbol) =>
875
- // it's an old-style conversion
876
- check()
877
- case _ =>
878
- }
879
- }
880
-
881
872
/** If `tree` is an application of a new-style implicit conversion (using the apply
882
873
* method of a `scala.Conversion` instance), check that implicit conversions are
883
874
* enabled.
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ given X/*->givens::X#*/ with
25
25
given (using X /* ->givens::X#*/ ): Y /* ->givens::Y#*/ with
26
26
def doY /* <-givens::InventedNames$package.given_Y#doY().*/ = " 7"
27
27
28
- given [T /* <-givens::InventedNames$package.given_Z_T#[T]*/ ]: Z /* ->givens::Z#*/ [T /* ->givens::InventedNames$package.given_Z_T#[T]*/ ] with
28
+ 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
29
29
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.*/
30
30
31
31
Original file line number Diff line number Diff line change @@ -1678,7 +1678,7 @@ Uri => InventedNames.scala
1678
1678
Text => empty
1679
1679
Language => Scala
1680
1680
Symbols => 45 entries
1681
- Occurrences => 61 entries
1681
+ Occurrences => 62 entries
1682
1682
1683
1683
Symbols:
1684
1684
givens/InventedNames$package. => final package object givens extends Object { self: givens.type => +24 decls }
@@ -1761,6 +1761,7 @@ Occurrences:
1761
1761
[24:17..24:18): Y -> givens/Y#
1762
1762
[25:6..25:9): doY <- givens/InventedNames$package.given_Y#doY().
1763
1763
[27:7..27:8): T <- givens/InventedNames$package.given_Z_T#[T]
1764
+ [27:7..27:8): T <- givens/InventedNames$package.given_Z_T().[T]
1764
1765
[27:11..27:12): Z -> givens/Z#
1765
1766
[27:13..27:14): T -> givens/InventedNames$package.given_Z_T#[T]
1766
1767
[28:6..28:9): doZ <- givens/InventedNames$package.given_Z_T#doZ().
You can’t perform that action at this time.
0 commit comments