File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed 
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
442442
443443  /**  The purity level of this reference. 
444444   *  @return  
445-    *    PurePath        if reference is (nonlazy and stable) or to a parameterized function 
445+    *    PurePath        if reference is (nonlazy and stable) 
446+    *                    or to a parameterized function 
447+    *                    or its type is a constant type 
446448   *    IdempotentPath  if reference is lazy and stable 
447449   *    Impure          otherwise 
448450   *  @DarkDimius: need to make sure that lazy accessor methods have Lazy and Stable 
@@ -452,6 +454,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
452454    val  sym  =  tree.symbol
453455    if  (! tree.hasType) Impure 
454456    else  if  (! tree.tpe.widen.isParameterless ||  sym.isEffectivelyErased) PurePath 
457+     else  if  tree.tpe.isInstanceOf [ConstantType ] then  PurePath 
455458    else  if  (! sym.isStableMember) Impure 
456459    else  if  (sym.is(Module ))
457460      if  (sym.moduleClass.isNoInitsClass) PurePath  else  IdempotentPath 
Original file line number Diff line number Diff line change @@ -727,7 +727,7 @@ object SymDenotations {
727727      */  
728728    final  def  isStableMember (implicit  ctx : Context ):  Boolean  =  {
729729      def  isUnstableValue  =  isOneOf(UnstableValueFlags ) ||  info.isInstanceOf [ExprType ]
730-       isType ||  is(StableRealizable ) ||  ! isUnstableValue
730+       isType ||  is(StableRealizable ) ||  exists  &&   ! isUnstableValue
731731    }
732732
733733    /**  Is this a denotation of a class that does not have - either direct or inherited - 
Original file line number Diff line number Diff line change @@ -1082,7 +1082,7 @@ object Types {
10821082    /**  Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol */  
10831083    final  def  widenIfUnstable (implicit  ctx : Context ):  Type  =  stripTypeVar match  {
10841084      case  tp : ExprType  =>  tp.resultType.widenIfUnstable
1085-       case  tp : TermRef  if  ! tp.symbol.isStableMember =>  tp.underlying.widenIfUnstable
1085+       case  tp : TermRef  if  tp.symbol.exists  &&   ! tp.symbol.isStableMember =>  tp.underlying.widenIfUnstable
10861086      case  _ =>  this 
10871087    }
10881088
Original file line number Diff line number Diff line change 1+ extension on (x : Array [Char ]): 
2+   inline  def  swap (i : Int , j : Int ) :  Unit  = 
3+     val  v  =  x(i)
4+     x(i)  =  x(j)
5+     x(j)  =  v
6+ 
7+ @ main def  Test  = 
8+   val  a  =  Array ('A' ,'B' )
9+   a.swap(0 , 1 )
10+   assert(a.toList ==  List ('B' , 'A' ))
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments