@@ -65,18 +65,21 @@ class UnrollDefinitions extends MacroTransform, IdentityDenotTransformer {
6565
6666 def computeIndices (annotated : Symbol )(using Context ): ComputedIndicies =
6767 unrolledDefs.getOrElseUpdate(annotated, {
68- val indices = annotated
69- .paramSymss
70- .zipWithIndex
71- .flatMap: (paramClause, paramClauseIndex) =>
72- val annotationIndices = findUnrollAnnotations(paramClause)
73- if (annotationIndices.isEmpty) None
74- else Some ((paramClauseIndex, annotationIndices))
75- if indices.nonEmpty then
76- // pre-validation should have occurred in posttyper
77- assert(annotated.is(Final , butNot = Deferred ) || annotated.isConstructor || annotated.owner.is(ModuleClass ),
78- i " $annotated is not final&concrete, or a constructor " )
79- indices
68+ if annotated.name.is(DefaultGetterName ) then
69+ Nil // happens in curried methods where more than one parameter list has @unroll
70+ else
71+ val indices = annotated
72+ .paramSymss
73+ .zipWithIndex
74+ .flatMap: (paramClause, paramClauseIndex) =>
75+ val annotationIndices = findUnrollAnnotations(paramClause)
76+ if (annotationIndices.isEmpty) None
77+ else Some ((paramClauseIndex, annotationIndices))
78+ if indices.nonEmpty then
79+ // pre-validation should have occurred in posttyper
80+ assert(annotated.is(Final , butNot = Deferred ) || annotated.isConstructor || annotated.owner.is(ModuleClass ) || annotated.name.is(DefaultGetterName ),
81+ i " $annotated is not final&concrete, or a constructor " )
82+ indices
8083 })
8184 end computeIndices
8285
@@ -103,7 +106,7 @@ class UnrollDefinitions extends MacroTransform, IdentityDenotTransformer {
103106 params
104107 .zipWithIndex
105108 .collect {
106- case (v, i) if v.annotations.exists(_.symbol.fullName.toString == " scala.annotation.unroll " ) =>
109+ case (v, i) if v.hasAnnotation(defn. UnrollAnnot ) =>
107110 i
108111 }
109112 }
@@ -303,7 +306,9 @@ class UnrollDefinitions extends MacroTransform, IdentityDenotTransformer {
303306 case _ => unreachable(" sliding with at least 2 elements" )
304307 Some ((defdef.symbol, None , generatedDefs))
305308
306- case multiple => sys.error(" Cannot have multiple parameter lists containing `@unroll` annotation" )
309+ case multiple =>
310+ report.error(" Cannot have multiple parameter lists containing `@unroll` annotation" , defdef.srcPos)
311+ None
307312 }
308313
309314 case _ => None
0 commit comments