File tree Expand file tree Collapse file tree 3 files changed +62
-2
lines changed 
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -1171,7 +1171,7 @@ object RefChecks {
11711171        def  explicit  =  Applications .stripImplicit(tp.stripPoly, wildcardOnly =  true )
11721172        def  hasImplicitParams  =  tp.stripPoly match  { case  mt : MethodType  =>  mt.isImplicitMethod case  _ =>  false  }
11731173      val  explicitInfo  =  sym.info.explicit //  consider explicit value params
1174-       val  target  =  explicitInfo.firstParamTypes.head //  required for extension method, the putative receiver
1174+       val  target  =  explicitInfo.firstParamTypes.head.typeSymbol.info  //  required for extension method, the putative receiver
11751175      val  methTp  =  explicitInfo.resultType //  skip leading implicits and the "receiver" parameter
11761176      def  hidden  = 
11771177        target.nonPrivateMember(sym.name)
@@ -1200,7 +1200,7 @@ object RefChecks {
12001200          sym.owner.info.member(getterName)
12011201        if  getterDenot.exists
12021202        then  report.warning(ExtensionHasDefault (sym), getterDenot.symbol.srcPos)
1203-       if  ! target.typeSymbol.isOpaqueAlias  &&   ! sym.nextOverriddenSymbol.exists &&  hidden
1203+       if  ! sym.nextOverriddenSymbol.exists &&  hidden
12041204      then  report.warning(ExtensionNullifiedByMember (sym, target.typeSymbol), sym.srcPos)
12051205  end  checkExtensionMethods 
12061206
Original file line number Diff line number Diff line change 1+ -- [E194] Potential Issue Warning: tests/warn/i22232.scala:3:23 --------------------------------------------------------
2+ 3 |  extension (c: C) def equals(that: Any): Boolean = false // warn
3+   |                       ^
4+   |                       Extension method equals will never be selected from type C
5+   |                       because C already has a member with the same name and compatible parameter types.
6+   |
7+   | longer explanation available when compiling with `-explain`
8+ -- [E194] Potential Issue Warning: tests/warn/i22232.scala:9:25 --------------------------------------------------------
9+ 9 |    extension (d: D) def equals(that: Any): Boolean = false // warn
10+   |                         ^
11+   |                         Extension method equals will never be selected from type C
12+   |                         because C already has a member with the same name and compatible parameter types.
13+   |
14+   | longer explanation available when compiling with `-explain`
15+ -- [E194] Potential Issue Warning: tests/warn/i22232.scala:13:38 -------------------------------------------------------
16+ 13 |  extension (arr: MyString[Byte]) def length: Int = 0 // warn
17+    |                                      ^
18+    |                          Extension method length will never be selected from type String
19+    |                          because String already has a member with the same name and compatible parameter types.
20+    |
21+    | longer explanation available when compiling with `-explain`
22+ -- [E194] Potential Issue Warning: tests/warn/i22232.scala:17:46 -------------------------------------------------------
23+ 17 |  extension [T <: MyString[Byte]](arr: T) def length: Int = 0 // warn
24+    |                                              ^
25+    |                          Extension method length will never be selected from type String
26+    |                          because String already has a member with the same name and compatible parameter types.
27+    |
28+    | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ class  C 
2+ object  C : 
3+   extension  (c : C ) def  equals (that : Any ):  Boolean  =  false  //  warn
4+ 
5+ object  X : 
6+   class  C 
7+   opaque  type  D  <:  C  =  C 
8+   object  D : 
9+     extension  (d : D ) def  equals (that : Any ):  Boolean  =  false  //  warn
10+ 
11+ object  Upperbound1 : 
12+   opaque  type  MyString [+ T ] <:  String  =  String 
13+   extension  (arr : MyString [Byte ]) def  length :  Int  =  0  //  warn
14+ 
15+ object  Upperbound2 : 
16+   opaque  type  MyString [+ T ] <:  String  =  String 
17+   extension  [T  <:  MyString [Byte ]](arr : T ) def  length :  Int  =  0  //  warn
18+ 
19+ object  Upperbound3 : 
20+   opaque  type  MyString [+ T ] <:  String  =  String 
21+   extension  [T ](arr : T ) def  length :  Int  =  0  //  nowarn
22+ 
23+ object  NonUpperbound1 : 
24+   opaque  type  MyString [+ T ] =  String 
25+   extension  (arr : MyString [Byte ]) def  length :  Int  =  0  //  nowarn
26+ object  NonUpperbound2 : 
27+   opaque  type  MyString [+ T ] =  String 
28+   extension  [T  <:  MyString [Byte ]](arr : T ) def  length2 :  Int  =  0  //  nowarn
29+ 
30+ object  NonUpperbound3 : 
31+   opaque  type  MyString [+ T ] =  String 
32+   extension  [T ](arr : T ) def  length :  Int  =  0  //  nowarn
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments