Skip to content

Commit

Permalink
Avoid testing null symbol of eta-expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Jun 23, 2023
1 parent 7db02fe commit 1770afe
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 @@ -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)
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 1770afe

Please sign in to comment.