Skip to content

Commit 33a086b

Browse files
committed
Handle TypeApply(fun, ...) for symbol-less funs
Such as class literals, as one could conjure in `classOf[Int][Int]` Before, this would crash with a `NullPointerException`
1 parent c243435 commit 33a086b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5051,7 +5051,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
50515051

50525052
// @M: fun is typed in TAPPmode because it is being applied to its actual type parameters
50535053
val fun1 = typed(fun, mode.forFunMode | TAPPmode)
5054-
val tparams = fun1.symbol.typeParams
5054+
val tparams = if (fun1.symbol == null) Nil else fun1.symbol.typeParams
50555055

50565056
//@M TODO: val undets_fun = context.undetparams ?
50575057
// "do args first" (by restoring the context.undetparams) in order to maintain context.undetparams on the function side.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class-of-double-targs.scala:2: error: expression of type Class[Int](classOf[scala.Int]) does not take type parameters.
2+
classOf[Int][Int]
3+
^
4+
one error found
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
classOf[Int][Int]
3+
}

0 commit comments

Comments
 (0)