File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed 
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -875,6 +875,10 @@ object TypeOps:
875875    }
876876
877877    def  instantiate ():  Type  =  {
878+       //  if there's a change in variance in type parameters (between subtype tp1 and supertype tp2)
879+       //  then we don't want to maximise the type variables in the wrong direction.
880+       //  For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any
881+       maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan )
878882      maximizeType(protoTp1, NoSpan )
879883      wildApprox(protoTp1)
880884    }
Original file line number Diff line number Diff line change 1+ //  scalac: -Werror
2+ sealed  trait  A [- Z ]
3+ final  case  class  B [Y ]() extends  A [Y ]
4+ 
5+ class  Test : 
6+   def  t1 [X ](a : A [X ]) =  a match  //  was inexhaustive
7+     case  _ : B [X ] @ unchecked => 
8+ 
9+ // def t2[X](a: A[X]) = a match // was inexhaustive
10+ //   case _: B[X] => // expected unchecked warning
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments