File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -116,9 +116,12 @@ class SyntheticMethods(thisTransformer: DenotTransformer) {
116
116
*/
117
117
def productElementBody (arity : Int , index : Tree )(implicit ctx : Context ): Tree = {
118
118
val ioob = defn.IndexOutOfBoundsException .typeRef
119
- // That's not ioob.typeSymbol.primaryConstructor, this is the other one
120
- // that takes a String argument.
121
- val constructor = ioob.typeSymbol.info.decls.toList.tail.head.asTerm
119
+ // Second constructor of ioob that takes a String argument
120
+ def filterStringConstructor (s : Symbol ): Boolean = s.info match {
121
+ case m : MethodType if s.isConstructor => m.paramInfos == List (defn.StringType )
122
+ case _ => false
123
+ }
124
+ val constructor = ioob.typeSymbol.info.decls.find(filterStringConstructor _).asTerm
122
125
val stringIndex = Apply (Select (index, nme.toString_), Nil )
123
126
val error = Throw (New (ioob, constructor, List (stringIndex)))
124
127
You can’t perform that action at this time.
0 commit comments