File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -174,14 +174,19 @@ object Implicits {
174
174
* Note that we always take the underlying type of a singleton type as the argument
175
175
* type, so that we get a reasonable implicit cache hit ratio.
176
176
*/
177
- def adjustSingletonArg (tp : Type ): Type = tp.widenSingleton match {
177
+ def adjustSingletonArg (tp : Type ): Type = tp.widenSingleton match
178
178
case tp : PolyType =>
179
179
val res = adjustSingletonArg(tp.resType)
180
- if ( res `eq` tp.resType) tp else tp.derivedLambdaType(resType = res)
180
+ if res eq tp.resType then tp else tp.derivedLambdaType(resType = res)
181
181
case tp : MethodType =>
182
182
tp.derivedLambdaType(paramInfos = tp.paramInfos.mapConserve(widenSingleton))
183
- case _ => tp
184
- }
183
+ case _ =>
184
+ tp.baseType(defn.ConversionClass ) match
185
+ case app @ AppliedType (tycon, from :: to :: Nil ) =>
186
+ val wideFrom = from.widenSingleton
187
+ if wideFrom ne from then app.derivedAppliedType(tycon, wideFrom :: to :: Nil )
188
+ else tp
189
+ case _ => tp
185
190
186
191
var ckind =
187
192
if (! ref.symbol.isAccessibleFrom(ref.prefix)) Candidate .None
@@ -1384,7 +1389,7 @@ trait Implicits { self: Typer =>
1384
1389
untpd.Select (
1385
1390
untpd.TypedSplice (
1386
1391
adapt(generated,
1387
- defn.ConversionClass .typeRef.appliedTo(argument.tpe.widen , pt),
1392
+ defn.ConversionClass .typeRef.appliedTo(argument.tpe, pt),
1388
1393
locked)),
1389
1394
nme.apply)
1390
1395
else untpdGenerated
Original file line number Diff line number Diff line change
1
+ import scala .language .implicitConversions
2
+
3
+ trait Fixture [A ] extends Conversion [0 , A ]
4
+
5
+ trait TestFramework [A ] {
6
+ def (testName : String ) in (test : (given Fixture [A ]) => Unit ): Unit = ???
7
+ }
8
+
9
+ trait Greeter {
10
+ def greet (name : String ): String = s " Hello $name"
11
+ }
12
+
13
+ case class MyFixture (name : String , greeter : Greeter )
14
+
15
+ object Test1 with
16
+ given conv : Conversion [0 , Greeter ]
17
+ def apply (x : 0 ): Greeter = ???
18
+ val g : Greeter = 0
19
+
20
+ class MyTest extends TestFramework [MyFixture ] {
21
+ " say hello" in {
22
+ assert(0 .greeter.greet(0 .name) == s " Hello ${0 .name}" )
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments