File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed 
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -844,6 +844,10 @@ trait ImplicitRunInfo:
844844            case  t : TypeVar  =>  apply(t.underlying)
845845            case  t : ParamRef  =>  applyToUnderlying(t)
846846            case  t : ConstantType  =>  apply(t.underlying)
847+             case  t @  AppliedType (tycon, args) if  ! tycon.typeSymbol.isClass => 
848+               //  To prevent arguments to be reduced away when re-applying the tycon bounds,
849+               //  we collect all parts as elements of a tuple. See i21951.scala for a test case.
850+               apply(defn.tupleType(tycon ::  args))
847851            case  t =>  mapOver(t)
848852        end  liftToAnchors 
849853        val  liftedTp  =  liftToAnchors(tp)
Original file line number Diff line number Diff line change 1+ class  A 
2+ object  A : 
3+   given  g [F [_]]:  F [A ] =  ??? 
4+ 
5+ object  Test : 
6+   summon[List [A ]] //  ok
7+   def  foo [F [_]] = 
8+     summon[F [A ]] //  error
9+ 
10+ final  case  class  X (val  i :  Int )
11+ object  X  {
12+   implicit  final  class  XOps [F [_]](xs : F [X ]) {
13+     def  unpack (implicit  ev : F [X ] <:<  Iterable [X ]):  Iterable [Int ] =  xs.map(_.i)
14+   }
15+ }
16+ 
17+ object  App  extends  App  {
18+   //  good
19+   val  ys :  List [X ] =  List (X (1 ))
20+   println(ys.unpack)
21+ 
22+   //  bad
23+   def  printPolymorphic [F [_]](xs : F [X ])(implicit  ev : F [X ] <:<  Iterable [X ]) =  {
24+     locally {
25+       //  implicit XOps is correct
26+       import  X .XOps 
27+       println(xs.unpack) //  found
28+     }
29+     //  but it's not being searched for in the companion object of X
30+     println(xs.unpack) //  error: unpack is not a member of F[X]
31+   }
32+   printPolymorphic[List ](ys)
33+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments