Skip to content

Commit

Permalink
Merge pull request #10443 from som-snytt/issue/12812-npe-dubious
Browse files Browse the repository at this point in the history
Avoid testing null symbol of eta-expansion
  • Loading branch information
lrytz committed Jun 26, 2023
2 parents eff3022 + 1770afe commit 93d6281
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5329,7 +5329,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)
Expand Down
8 changes: 8 additions & 0 deletions test/files/pos/t12812.scala
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 93d6281

Please sign in to comment.