File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed 
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1010,13 +1010,25 @@ object Parsers {
10101010      skipParams()
10111011      lookahead.isColon
10121012      &&  {
1013+         lookahead.nextToken()
10131014        ! sourceVersion.isAtLeast(`3.6`)
10141015        ||  { //  in the new given syntax, a `:` at EOL after an identifier represents a single identifier given
10151016             //  Example:
10161017             //     given C:
10171018             //       def f = ...
1018-           lookahead.nextToken()
10191019          ! lookahead.isAfterLineEnd
1020+         } ||  {
1021+             //  Support for for pre-3.6 syntax where type is put on the next line
1022+             //  Examples:
1023+             //      given namedGiven:
1024+             //        X[T] with {}
1025+             //      given otherGiven:
1026+             //        X[T] = new X[T]{}
1027+           lookahead.isIdent &&  {
1028+             lookahead.nextToken()
1029+             skipParams()
1030+             lookahead.token ==  WITH  ||  lookahead.token ==  EQUALS 
1031+           }
10201032        }
10211033      }
10221034
Original file line number Diff line number Diff line change 1+ 
2+ trait  Foo [T ]: 
3+   def  foo (v : T ):  Unit 
4+ 
5+ given  myFooOfInt : 
6+   Foo [Int ] with 
7+   def  foo (v : Int ):  Unit  =  ??? 
8+ 
9+ given  myFooOfLong : 
10+   Foo [Long ] =  new  Foo [Long ] {
11+     def  foo (v : Long ):  Unit  =  ??? 
12+   }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments