diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 66e2ed034c63..5cf7cdfb3782 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -5326,7 +5326,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // xml member to StringContext, which in turn has an unapply[Seq] method) def checkDubiousAdaptation(sel: Tree): Unit = if (!isPastTyper && settings.lintNumericMethods) { - val dubious = ScalaIntegralValueClasses(qualTp.typeSymbol) && ( + val dubious = ScalaIntegralValueClasses(qualTp.typeSymbol) && sel.symbol != null && ( sel.symbol.owner.eq(BoxedFloatClass) || sel.symbol.owner.eq(RichFloatClass)) if (dubious) context.warning(tree.pos, s"dubious usage of ${sel.symbol} with integer value", WarningCategory.LintNumericMethods) diff --git a/test/files/pos/t12812.scala b/test/files/pos/t12812.scala new file mode 100644 index 000000000000..79c35540b26e --- /dev/null +++ b/test/files/pos/t12812.scala @@ -0,0 +1,8 @@ + +// scalac: -Werror -Xsource:3 -language:postfixOps -Xlint + +class C { + def foo(max: Int) = (1 to max).map(1 to).foreach(r => println(r.mkString(","))) +} + +//java.lang.NullPointerException: Cannot invoke "scala.reflect.internal.Symbols$Symbol.owner()" because the return value of "scala.reflect.internal.Trees$Tree.symbol()" is null