You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The signature of getMethod is Method getMethod(String name, Class<?>... parameterTypes), so the second argument after typing should be an empty array of type Array[Class[_]], but instead we produce an empty array of type Array[Nothing]:
defassignType(tree: untpd.SeqLiteral, elems: List[Tree])(implicitctx: Context) = tree match {
casetree: JavaSeqLiteral=>
tree.withType(defn.ArrayOf(ctx.typeComparer.lub(elems.tpes).widen))
We set the array element type to the lub of the types of the JavaSeqLiteral elements, but when the JavaSeqLiteral is empty, the lub is Nothing.
We could fix the type by hand in TypedApply#makeVarArg where the expected type is known, but if we do this then -Ycheck will fail since retyping will produce Array[Nothing] again.
The text was updated successfully, but these errors were encountered:
The following crashes at runtime, because the second argument to
getMethod
(an empty vararg) is incorrectly typed:The signature of
getMethod
isMethod getMethod(String name, Class<?>... parameterTypes)
, so the second argument after typing should be an empty array of typeArray[Class[_]]
, but instead we produce an empty array of typeArray[Nothing]
:This is incorrect because
Array[Nothing]
is not a subtype ofArray[Class[_]]
and it blows up at runtime:The issue is in
TypeAssigner#assignType
:We set the array element type to the lub of the types of the
JavaSeqLiteral
elements, but when theJavaSeqLiteral
is empty, the lub isNothing
.We could fix the type by hand in
TypedApply#makeVarArg
where the expected type is known, but if we do this then-Ycheck
will fail since retyping will produceArray[Nothing]
again.The text was updated successfully, but these errors were encountered: